angular-upload icon indicating copy to clipboard operation
angular-upload copied to clipboard

IE iframe upload sending always http response status 200

Open bansaltushar opened this issue 9 years ago • 5 comments

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.

bansaltushar avatar Jun 22 '16 11:06 bansaltushar

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

wangcansunking avatar Jul 21 '16 01:07 wangcansunking

Will you be submitting this code in the library code?

bansaltushar avatar Jul 21 '16 06:07 bansaltushar

I have pull request

wangcansunking avatar Jul 21 '16 07:07 wangcansunking

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?

mittalbhanderi avatar Feb 03 '17 11:02 mittalbhanderi

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

zsj621 avatar Feb 15 '17 14:02 zsj621