我正在尝试使用angular上传文件,除了在IE9上,它运行得很好。
我尝试过https://github.com/danialfarid/ng-file-upload,但在使用非HTML5浏览器时需要使用Flash,所以它不适用于我。
在那之后,我尝试了https://github.com/nervgh/angular-file-upload,并且工作了!除了上传文件后,我做了一些处理,可能会返回一个错误的错误请求。这在IE9中是行不通的。如果上传成功,我的代码看不到Bad Request。
好吧,我真的不认为问题出在我的代码上,所以我不会在这里发表任何东西。我想要的是一个有同样问题的人,让我知道该怎么做。
编辑:换句话说。在Chrome中,状态是400,在IE9中是200。
uploader.onCompleteItem = function (fileItem, response, status, headers)EDIT2:我想我找到了错误的来源。这是一个角度文件上传函数
iframe.bind('load', function() {
try {
// Fix for legacy IE browsers that loads internal error page
// when failed WS response received. In consequence iframe
// content access denied error is thrown becouse trying to
// access cross domain page. When such thing occurs notifying
// with empty response object. See more info at:
// http://stackoverflow.com/questions/151362/access-is-denied-error-on-accessing-iframe-document-object
// Note that if non standard 4xx or 5xx error code returned
// from WS then response content can be accessed without error
// but 'XHR' status becomes 200. In order to avoid confusion
// returning response via same 'success' event handler.
// fixed angular.contents() for iframes
var html = iframe[0].contentDocument.body.innerHTML;
} catch (e) {}
var xhr = {response: html, status: 200, dummy: true};
var headers = {};
var response = that._transformResponse(xhr.response, headers);
that._onSuccessItem(item, response, xhr.status, headers);
that._onCompleteItem(item, response, xhr.status, headers);但我的回答总是模糊不清
发布于 2015-06-19 07:12:44
我想出了一个解决办法。在我的项目中,只有在服务器返回错误时,它才会输入catch语句。所以我在这里触发了事件onError。
https://stackoverflow.com/questions/30922652
复制相似问题