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

download, html, internet-explorer

Solution

The download attribute is not supported in IE (see http://caniuse.com/#search=download%20attribute).

That suggests the download attribute is only supported by firefox, chrome, opera and the latest version of blackberry's browser.

For other browsers you'll need to use more traditional methods to force download. That is server side code is necessary to set an appropriate Content-Type and Content-Disposition header to tell (or trick depending on your point of view) the browser to download the item. Headers should look like this:

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

(thanks to antyrat for the copy and paste of the headers)

Problem

``` <a href="path/to/file/filename.xxx" download="filename.xxx">filename</a>' ``` When i click the link, my filename.xxx should be downloaded. It works perfectly in chrome. But in Internet explorer, it opens the file instead of downloading. What could be the problem? Is there any properties that is to be added to make it work in ie. And also i need a file download sample that works for all the browsers.

Original source

Related problems