PDA

View Full Version : Help with 'filefield' control in IE 9



brothnie
4 Sep 2014, 10:49 AM
Hello all,

I am working on an app that allows users to upload an XML file via the filefield control in ExtJS 4.2.2. The issue that I am having is the file will save to the local file system; however, IE intercepts the successful return from the file being saved to the server as a file that needs to be downloaded. This causes the code to never return to the JavaScript code, thus never running my callback function for the form.submit() function.

Please note that I have attached the file that is returned from the successful server call. IE 9 is assuming this file, which should be just return of successful save data, as a file that is downloaded from the internet.

The code is working on Mozilla Firefox and I have copied the examples from the Ext API almost verbatim.

Any help is greatly appreciated!
Thanks!

50228

Gary Schlosberg
4 Sep 2014, 11:49 AM
I haven't heard of an issue like this. Can you please post the code for your form?

dougbieber
18 Sep 2014, 9:25 AM
Per the documentation:



The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the Content-Type header must be set to "text/html" in order to tell the browser to insert the text unchanged into the document body.


http://docs.sencha.com/extjs/4.2.2/#!/api/Ext.data.Connection


If I understand your problem correctly you'll need the return mime type to be text/html. Otherwise the success and failure aren't called. You keep referring to a "file" being returned. It should be in the response, not a file. Just trying to clarify the language.

devtig
2 Apr 2015, 10:06 PM
I haven't heard of an issue like this. Can you please post the code for your form?

It's a known problem.

http://stackoverflow.com/questions/23203813/ext-js-filefield-issue-in-internet-explorer8-and-9
http://stackoverflow.com/questions/18571719/extjs-file-uploading-error-on-ie8-ie9
http://www.sencha.com/forum/showthread.php?177605-4.x-Fileupload-gets-stuck
In Ext JS (http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Basic-method-hasUpload), file uploads are not performed using normal 'Ajax' techniques, that is they are not performed using XMLHttpRequests. Instead a hidden <form> element containing all the fields is created temporarily and submitted with its target set to refer to a dynamically generated, hidden <iframe> which is inserted into the document but removed after the return data has been gathered.
MartinMB answer is essentially correct. This answers aims to provide a little bit more background.


The server response is parsed by the browser to create the document for the IFRAME. If the server is using JSON to send the return object, then the `Content-Type` header must be set to `text/html` in order to tell the browser to insert the text unchanged into the document body.


Chrome, FF, IE10 and up do just when when they see `Content-Type` = `application/json` in the response header. However when you do that to IE8 and IE9, when the server reponds from the file upload, you see a message saying something along the lines of: "Do you want to open or save this document"?


So, to fix that in IE8 and IE9, just set `Content-Type` to `text/html` and you're fine. The modern browsers responds just the same, so you're not breaking anything there with that solution.