<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.
Click on "Settings" and you'll see a new page pop up in your Chrome browser window. Scroll down to Advanced Settings, click Downloads, and clear your Auto Open options. Next time you download an item, it will be saved instead of opened automatically.
There are tens of reasons which can cause this issue of downloading files instead of opening in browser. But mainly you get this issue due to poor hosting provider, any deflect in cache plugin you're using on your website, or you messed up with the . htaccess file.
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)
It should be fixed on server side. Your server should return this headers for this file types:
Content-Type: application/octet-stream Content-Disposition: attachment;filename=\"filename.xxx\"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With