PDA

View Full Version : Content-Type for file upload?



critchdizzle
30 Apr 2015, 8:02 AM
I was reading through documentation trying to troubleshoot an intermittent issue one of our clients is reporting and I noticed that when posting a file upload request in Ext 3.4 (which is what one of our applications is using) and the server is returning JSON, the Content-Type header returning from the server needs to be "text/html." In Ext 5, (which one of our other applications is using) it needs to be "text/plain". Is this difference because of the way the different versions of Ext handle the response? Or is this because of the way the browser itself handles the response? If it's because of the browser, which one do I need to use when returning JSON to a file upload request posted using 3.4?

Thanks for your help.

Gary Schlosberg
30 Apr 2015, 3:45 PM
From the doc page (http://docs.sencha.com/extjs/3.4.0/#!/api/Ext.form.BasicForm-cfg-fileUpload), it looks like the Content-Type should be 'text/html':



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.

critchdizzle
30 Apr 2015, 4:02 PM
I saw that, I was just wondering what the reason for the change was between 3.4 and 5.