1-----------------------------------form.html---------------------------------------
Documentfunction send(){
var pic = document.getElementsByTagName('input')[0].files[0];
var fd = new FormData();
fd.append('pic',pic);
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function(){
if( this.readyState == 4 && this.status == 200 ){
document.getElementById('info').innerHTML = this.responseText;
}
}
xmlhttp.open('POST','upload.php',true);
xmlhttp.send(fd);
}
--------------------------------------upload.php-------------------------------------
if(move_uploaded_file($_FILES['pic']['tmp_name'],'./upload/'.$_FILES['pic']['name'] )){
echo '上传成功 ';
}else{
echo '上传失败';
}
?>