开发者

Force browser to download

I'm using a .htaccess file to make links to JPEGs download instead of openin开发者_开发百科g in the browser window. This is what I'm using:

    AddType application/octet-stream .jpg

It's working fine in Safari and Firefox on Mac OSX but not on IE 8 on Windows. Is there any way around this apart from writing a header in PHP which I would rather not do?


I think Internet Explorer does also expect Content-Disposition: attachment for downloads. If you have mod_headers available, you can do this:

<FilesMatch "\.jpg$">
    Header set Content-Disposition attachment
    Header set Content-Type application/octet-stream
</FilesMatch>


I found some tutorials which use another method that should work for you:

  1. Here
  2. and Here


Add header("Content-disposition: attachment; filename=..."); in PHP

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜