leon / angular-upload

Upload service with iframe fallback and some nice directives to go with it.
MIT License
234 stars 100 forks source link

IE iframe upload sending always http response status 200 #65

Open bansaltushar opened 8 years ago

bansaltushar commented 8 years ago

When we try to submit a form with an angular-upload element, then in case there is an exception generated by the server which returns an http status 500, but since in IE the upload is taking place through the iframe, the angular-upload directive is always returning the http status to 200 due to which the responseError interceptor is not getting invoked. Kindly check and fix this issue. Thanks.

wangcansunking commented 8 years ago

To add a defferred.reject function in the iframe off load function catch will solve the problem.

try {
                        var doc = this.contentWindow ? this.contentWindow.document : this.contentDocument;
                        response = angular.element(doc.body).text();
                        // Google Chrome and Firefox do not throw an
                        // exception when calling iframe.contents() on
                        // cross-domain requests, so we unify the response:
                        if (!response.length) {
                            throw new Error();
                        }
                    } catch (e) {
                        deferred.reject({
                            data: {
                                message: '文件上传失败!'
                            }
                        });
                        return;
                    }
bansaltushar commented 8 years ago

Will you be submitting this code in the library code?

wangcansunking commented 8 years ago

I have pull request

mittalbhanderi commented 7 years ago

It still doesn't work for me in IE9. Once I select a file to upload IE prompts me the save the file..

Anyone noticed this kind of behaviour before?

zsj621 commented 7 years ago

For IE8 or IE9, the Content-Type in Response Header should be 'text/html'.