PDA

View Full Version : Download attachment in IE10 not working



khushboo_nf
9 Feb 2014, 11:21 PM
Hi,

I am trying to download an attachment in on a click event. The code after the clicking event is pasted below:


Ext.Ajax.request({ url: '/DPS_BE/StudyVersionControlServlet?action=downloadVerStudy',
method:'GET',
params: {
stuID : study,
version : version
},
success: function(response){

box.hide();
var link = document.createElement("a");
link.download = studyName+'_V'+version+'.doc';
link.href = '/DPS_BE/temp/workingSOVDir/sov.doc';
link.click();


},
failure: function(response){
box.hide();
Ext.Msg.alert('Server Error');
}

});


Now the doc file is downloading perfectly fine in chrome, but NOT in IE-10. Please let me know the solution ASAP, as it is halting my crucial deliverable.

N.B.: I have tried to set the response type to "text/html" , "application/msword", "text/plain". But no success.. :-/

skirtle
10 Feb 2014, 7:16 AM
It doesn't look like IE has support for the download attribute:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a#Specifications

The standard way to do downloads is using a Content-Disposition header, often in conjunction with a hidden iframe.

khushboo_nf
10 Feb 2014, 11:16 PM
Thanks for the help.
Can I get the code snippet for download using Iframe? :s:s

skirtle
11 Feb 2014, 2:20 AM
Discussed here, among other places:

http://www.sencha.com/forum/showthread.php?246673

In your case you don't need a form, for a GET request it's just a case of setting the src.

The key thing is the server-side header. You can find out more about that with a quick Google search.