File Downloads with php in Internet Explorer
Wednesday, November 26th, 2008For a web project with restricted access I wrote a script to download files via php. Basically I use rewrite rules to send the user to the php script, the script checks if the session is ok and sends the download (prepended by several headers) if the user has the proper permissions and the file is located in a directory that’s whitelisted.
Here’s the RewriteRule:
- RewriteRule ^/(downloads/.*) https://www.server.org/download.php?f=$1 [L,R,NC]
It worked fine except … Internet Explorer. In some cases, IE6 refused to save the file correctly. It just saved it with the name download.php and “unknown type”. Regardless of the type I sent along with Content-type and the name I sent with Content-Disposition.
(more…)