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

前端 未结 8 1837
萌比男神i
萌比男神i 2020-11-30 11:13
filename\'

When i click the link, my filename.xxx should be downloa

8条回答
  •  [愿得一人]
    2020-11-30 11:42

    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)

提交回复
热议问题