Force save files all browsers - not open in browser window

Posted by Joshc on Stack Overflow See other posts from Stack Overflow or by Joshc
Published on 2012-04-03T16:07:50Z Indexed on 2012/07/05 21:16 UTC
Read the original article Hit count: 315

Filed under:
|

I'm after a simple solution to work in all browsers.

For specific file types, or targeted links via a class: how can I get them to simply force download in all major browsers.

I thought I found the perfect solution for apachce server - by adding this into the .htaccess.

http://css-tricks.com/snippets/htaccess/force-files-to-download-not-open-in-browser/

AddType application/octet-stream .csv
AddType application/octet-stream .xls
AddType application/octet-stream .doc
AddType application/octet-stream .avi
AddType application/octet-stream .mpg
AddType application/octet-stream .mov
AddType application/octet-stream .pdf

Seems to work in Firefox and Safari, but not chrome or IE (have not tested anything else)

Can any one please help me with a solution on how to make links to force download the file, instead of opening in the browser, for ALL browsers.

I can't seem to find a full browser proof solution. Is it not possible?

Any links to tutorial or snippets would be awesome.

My website if PHP based so can make it work with PHP if posible.

Thanks

© Stack Overflow or respective owner

Related posts about php

Related posts about file-download