PHP, IE and file downloads

Thursday, 20. 10. 2005  –  Category: web

A developer I work with was having problems with some PHP code that generates a spreadsheet for download over https. It all worked swimmingly on Firefox, Safari etc, but not Internet Explorer which would promptly error with a ‘file not found’ dialog box. The Content-Type header was variously ‘application/octet-stream’ and ‘application/’, but neither worked.

PHP defaults to sending nocache headers, and this makes IE aggressively zap any temporary files that arise, even if they’re destined for another app locally.

We fixed this by setting PHP’s cache limiter knob on a per-download basis, although it can be done system-wide also. Here’s the page in the PHP manual.

Whilst investigating this, I encountered the ugly truth about IE’s mime-type handling. Seems fiddly!

Leave a Reply