IE11
在尝试使用XMLHttpRequest
以下文件上传文件时,收到上述错误后,我偶然发现了这些问题和答案:
var reqObj = new XMLHttpRequest();
//event Handler
reqObj.upload.addEventListener("progress", uploadProgress, false);
reqObj.addEventListener("load", uploadComplete, false);
reqObj.addEventListener("error", uploadFailed, false);
reqObj.addEventListener("abort", uploadCanceled, false);
//open the object and set method of call (post), url to call, isAsynchronous(true)
reqObj.open("POST", $rootUrlService.rootUrl + "Controller/UploadFiles", true);
//set Content-Type at request header.for file upload it's value must be multipart/form-data
reqObj.setRequestHeader("Content-Type", "multipart/form-data");
//Set header properties : file name and project milestone id
reqObj.setRequestHeader('X-File-Name', name);
// send the file
// this is the line where the error occurs
reqObj.send(fileToUpload);
删除线reqObj.setRequestHeader("Content-Type", "multipart/form-data");
解决了问题。
注意:此错误在其他浏览器中的显示方式非常不同。即Chrome浏览器显示类似于连接重置的内容,类似于Fiddler报告的内容(由于突然关闭连接导致响应为空)。
此外,仅当从与WebServer
(不同于localhost的其他机器)上的另一台机器完成上传时,才会出现此错误。