Home >php教程 >php手册 >二款php ajax文件上传代码(1/4)

二款php ajax文件上传代码(1/4)

WBOY
WBOYOriginal
2016-06-13 11:24:56859browse

二款php ajax文件上传代码这两款ajax文件上传代码其实都是利用了js的iframe或ajax post来实现的下面来看看代码吧。

二款php教程 ajax文件上传代码
这两款ajax文件上传代码其实都是利用了js的iframe或ajax post来实现的下面来看看代码吧。



ajax file upload sample




<br><script language="网页特效"> <br />// 上传函数 <br />function btn_send.onclick() { <br />data = "" <br />spliter = "-------7d8d733180846" <br />datadata = data + spliter + "rn" <br />datadata = data + "content-disposition: form-data; name="photofile"; filename="c:a.txt"rn" <br />// datadata = data + "content-type: image/pjpeg" + vbcrlf <br />datadata = data + "content-type: text/plain" + "rn" + "rn" <br />text = "my name is wilson lin." <br />postlength = text.length + data.length + 2 + spliter.length + 4 <br />package = data + text + "rn" + spliter + "--rn"<p>alert(package) <br />// 把xml文档发送到web服务器 <br />var xmlhttp = new activexobject("microsoft.xmlhttp"); <br />xmlhttp.open("post","./upload.php",false); <br />xmlhttp.setrequestheader("content-type", "multipart/form-data; boundary=-----7d8d733180846"); <br />xmlhttp.setrequestheader("content-length", postlength); <br />xmlhttp.send(package); <br />// 显示服务器返回的信息 <br />result.innerhtml=xmlhttp.responsetext; <br />} <br /></script> <br>





 





 

1 2 3 4

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn