日期:2014-05-16 浏览次数:20823 次
var fd = new FormData();
fd.append("FileData",document.getElementById('upload_file').files);
var xhr = XMLHttpRequest();
//xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.addEventListener("load", uploadComplete, false);
xhr.addEventListener("error", uploadFailed, false);
xhr.addEventListener("abort", uploadCanceled, false);
xhr.onreadystatechange=mycallback;
xhr.open("POST", url);
xhr.setRequestHeader("X-Requested-With","XMLHttpHequest");
xhr.setRequestHeader('Content-Type','multipart/form-data;boundary=---------------------------' + new Date().getTime());
xhr.send(fd);
string sPath = context.Server.MapPath(@"../../UploadFile");
for (int i = 0; i < context.Request.Files.Count;i++ )
{
HttpPostedFile file = context.Request.Files[i];
file.SaveAs(sPath + "\\" + file.FileName);
}