4

I have some files uploaded on Amazon S3. On other browsers like Firefox and Chrome, I can click and browser will automatically download. But in IE11, it shows directly on browser. And I want to trigger "save target as" on IE11 to download this file. How can I do that? Here is my HTML:

<a href="<link>" target="_blank">1.xlsx</a>
Snow Fox
  • 389
  • 6
  • 15

2 Answers2

2

The short answer is, you can't. Whether a browser downloads the file or displays it in the browser, that is a browser setting and not something you can directly control, due to it simply being a link to the file directly.

However, if you have access to PHP, you can change the HTML Headers so the browser explicitly downloads the content instead of being allowed to do whatever it wants.

Force file download with php using header()

Community
  • 1
  • 1
Nelson
  • 2,040
  • 17
  • 23
1

As well as what @Nelson suggested, You can also do this with .htaccess

<FilesMatch "\.(?i:doc|odf|pdf|rtf|txt)$">
    ForceType application/octet-stream
    Header add Content-Disposition "attachment"
</FilesMatch>
Mi-Creativity
  • 9,554
  • 10
  • 38
  • 47