自己写啊!
<?phpheader("Content-type:text/html;charset=utf-8");
print_r($_FILES['file']);
$filename=$_FILES['file']['name'];
if(!$_FILES['file']['error'])
{
if(move_uploaded_file($_FILES['file']['tmp_name'],"./upload/".$filename))
{
echo "文件上传成功";
}else{
echo "文件上传失败";
}
}else{
echo "文件上传错误";
}
?>
/**
* 上传
*/
// 自封装纯js ajax post 上传方法
function jsPost(url, data, s, e) {
var xhr = new XMLHttpRequest();
xhr.open('POST', upload.php);//这里注意调用的路径要正确
xhr.onreadystatechange = function() {
if (xhr.readyState == 4) {
if (xhr.status == 200 || xhr.status == 304) {
s(xhr.responseText);
} else if (xhr.status >= 400) {
e(xhr.responseText);
}
}
}
xhr.send(data);
}