NYCPHP Meetup

NYPHP.org

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

pswebcode, nyc psaw at pswebcode.com
Wed Sep 3 16:21:31 EDT 2003


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




More information about the talk mailing list