PHP file download error in Internet Explorer 7
October 9th, 2008 by Anthony Curreri
When trying to download a file that is auto-generated on the fly by a PHP script I wrote that sends excel headers, Internet Explorer users were getting the error:
Windows Internet Explorer
Internet Explorer cannot download [filename] from [website].
Internet Explorer was not able to open this Internet site. The requested site is either unavailable or cannot be found. Please try again later.
This is caused by doing a session_start(). If you don’t actually need a the session in your php file you can remove it, and IE users will be able to download whatever your PHP script is making. The problem is session_start() by default sends a cache control header including “no-store”. Internet Explorer has a bug with sending a cache header.
If you need the session, then before session_start(), add “session_cache_limiter(’none’);”
Problem solved!
If you found this helpful, help me by checking out the ads on the right. Thank you!
Link to this post! Copy and paste this code into your blog or website:
