您好,登錄后才能下訂單哦!
-----------------------------------form.html---------------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<script type="text/javascript">
function 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);
}
</script>
</head>
<body>
<div id="info"></div>
<form action="">
<input type="file" onchange="send()" />
</form>
</body>
</html>
--------------------------------------upload.php-------------------------------------
<?php
if(move_uploaded_file($_FILES['pic']['tmp_name'],'./upload/'.$_FILES['pic']['name'] )){
echo '上傳成功 ';
}else{
echo '上傳失敗';
}
?>
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。