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:
- Here
- and Here
Add header("Content-disposition: attachment; filename=...");
in PHP
精彩评论