alert(package)
// 把XML文档发送到Web服务器
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
xmlhttp.open("POST","./upload.php",false);
xmlhttp.setRequestHeader("Content-Type", "multipart/form-data; boundary=-----7d8d733180846");
xmlhttp.setRequestHeader("Content-Length", postLength);
xmlhttp.send(package);
// 显示服务器返回的信息
result.innerHTML=xmlhttp.ResponseText;
}
</SCRIPT>
</PRE>
</body>
</html>
PHP服务器端代码: upload.php
代码如下:
<?php
// $_FILES['photofile']:是获得上传图片的数组
// $uploadfile:存放地址
$uploadfile = "D:/".$_FILES['photofile']['name'];
copy( $_FILES['photofile']['tmp_name'], $uploadfile );
echo "URL: <a href='http://localhost/".$_FILES['photofile']['name']."' target='_blank'>".$_FILES['photofile']['name']."</a><br/>";
?>
Upload successed!
声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。TEL:177 7030 7066 E-MAIL:11247931@qq.com