1

我正在尝试使用 Angular 上传文件,除了在 IE9 上它工作得很好。

我试过https://github.com/danialfarid/ng-file-upload但在使用非 HTML5 浏览器时需要 Flash,所以它对我不起作用。

之后我尝试了https://github.com/nervgh/angular-file-upload并且可以工作!除了上传文件后我做了一些处理,可能会通过错误请求返回错误。这在 IE9 中不起作用。如果上传成功,我的代码看不到错误请求。

好吧,我真的不认为问题出在我的代码上,所以我不会在这里发布任何内容。我想要的是有同样问题的人来告诉我该怎么做。

编辑:换句话说。在 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);

但我的反应总是不确定

4

1 回答 1

0

我想出一个解决办法。在我的项目中,如果服务器返回错误,它只会输入 catch 语句。所以我在那里触发了 onError 事件。

于 2015-06-18T23:12:44.467 回答