File opens instead of downloading in internet explorer in a href link

HTML and CSS and all web / frontend developmenet related topics
Post Reply
User avatar
NodeR
Posts: 46
Joined: Wed Oct 18, 2017 10:30 am

File opens instead of downloading in internet explorer in a href link

Post by NodeR » Sun Feb 11, 2018 9:28 am

<a

Code: Select all

path/to/file/filename.xxx" download="filename.xxx">< a href="http://path/to/file/ filename.xxx" download="filename.xxx" > filename' 
When i click the link, my filename.xxx must be downloaded. It works perfectly in chrome. But in Web explorer, it opens the file instead of downloading. Exactly what could be the issue? Exists any homes that is to be added to make it operate in ie. As well as i require a file download sample that works for all the browsers.

User avatar
Mizuo
Posts: 57
Joined: Thu Sep 14, 2017 10:24 am

Re: File opens instead of downloading in internet explorer in a href link

Post by Mizuo » Wed Feb 14, 2018 6:21 pm

The download characteristic is not supported in IE (see http://caniuse.com/#search=download characteristic). That suggests the download attribute is just supported by firefox, chrome, opera and the latest version of blackberry's internet browser. For other web browsers you'll need to use more conventional methods to force download. That is server side code is needed to set a suitable Content-Type and Content-Disposition header to inform (or technique depending on your perspective) the browser to download the item. Headers ought to appear like this:

Code: Select all

 Content-Type: application/octet-stream
Content-Disposition: accessory; filename =\" filename.xxx \" 
(thanks to antyrat for the copy and paste of the headers)

User avatar
Replay
Posts: 50
Joined: Tue Oct 10, 2017 2:58 pm

Re: File opens instead of downloading in internet explorer in a href link

Post by Replay » Thu Mar 01, 2018 8:21 pm

It need to be repaired on server side. Your server should return this headers for this file types:

Code: Select all

 Content-Type: application/octet-stream
Content-Disposition: accessory; filename =\" filename.xxx \" 

Post Reply