NYCPHP Meetup

NYPHP.org

[nycphp-talk] Force File Download HTTP Headers and IE Issue

max goldberg max at idsociety.com
Wed Sep 3 18:15:05 EDT 2003


I had this problem quite a few months ago. I don't remember what exactly
causes the problem, but I remember the solution was that I was forced to
write the file to disk, and then open it back up and shoot it out.

A similar problem occurs with mod_rewrite and IE6 from a bug thats been
in IE6 for > 2 years. They are pretty lazy when it comes to fixing stuff
like this.

Anyway, try writing the file to disk first and see if that helps.

-Max

pswebcode, nyc wrote:

> My question:
> Anyone got a working runaround suggestion to force file downloads on IE?
> 
> My issue(s):
> I am using PHP to write HTTP headers to force pdf file download to user
> roughly as follows:
> 
> blah, authenticate user, blah, select $file, blah... then push with...
> 
> header ("Content-Type: application/octet-stream");
> header("Content-Transfer-Encoding: Binary");
> header("Content-Length: $iFileSize");
> header ("Content-Disposition: attachment; filename=$iFileName");
> readfile("$file");
> 
> Netscape conforms and opens the Save As... dialog as expected. IE6 messes up
> the content-disposition header and opens the download inline in the browser
> without prompting user to Save As...
> 
> Seems regardless, of content-type header specified:
> application/octet-stream
> application/force-download
> application/pdf
> 
> IE will mess it up. This is a known issue. Best run around I've seen so far
> is to .Zip the files, in which case IE offers the Save As... on the
> download. Don't want to zip em. 
> 
> Thoughts?
> 
> Warmest regards,
> 
> Peter Sawczynec, Technology Director
> PSWebcode -- Web Development and 
> Site Architecture
> psaw at pswebcode.com
> www.pswebcode.com
> 718.543.3240
> 
> _______________________________________________
> talk mailing list
> talk at lists.nyphp.org
> http://lists.nyphp.org/mailman/listinfo/talk




More information about the talk mailing list