Internet Explorer 9 and angular-file-upload not working properly

2.5k views Asked by At

I'm trying to use upload a file using angular and it works very well except on IE9.

I tried https://github.com/danialfarid/ng-file-upload but requires Flash when working with non-HTML5 browsers, so it does not work for me.

After that I tried https://github.com/nervgh/angular-file-upload and works! Except that after uploading the file I do some processing and maybe return an error by Bad Request. And this does not work in IE9. If the upload is successful my code does not see the Bad Request.

Well, I really don't think that the problem is my code, so I wont post anything here. What I want is someone who had the same problems to shed me some light in what to do.

EDIT: In other words. In Chrome, status is 400 and in IE9 is 200.

uploader.onCompleteItem = function (fileItem, response, status, headers)

EDIT2: I think I found the source of the error. This is a angular-file-upload function

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);

But my response is always undefined

1

There are 1 answers

3
Rafael P. Miranda On

I figure out a fix. In my project it only enters the catch statement if the server returned an error. So there I fire the event onError.