NYCPHP Meetup

NYPHP.org

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

Brian Pang bpang at bpang.com
Wed Sep 3 16:36:03 EDT 2003


I think this has been addressed in the archives already..
but maybe not specific to PDF

this works for me. Still prompts to save, but fills in the filename.
Does it work for you?


header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$filename\"");
$fd=fopen("$filePath","r");
fpassthru($fd);


> 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