Forum Moderators: coopster
$path = $_SERVER["DOCUMENT_ROOT"]."/members/thefile.pdf";
$download_size = filesize($path);
// force download dialog
header("Content-Type: application/force-download");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Content-Transfer-Encoding: binary");
header("Accept-Ranges: bytes");
header("Content-Length: ".$download_size);
header('Content-Disposition: attachment; filename=newfile.pdf');
readfile("thefile.pdf");
Even when firefox users download this file it can often be corrupt. This is just one version and combination I've tried but trust me I've tried so many different combinations and I've looked at other forums and even header() discussions in PHP.net
If anyone has encountered this problem and has found a fix it would be appreciated!
Thanks
Generating a CSV for Download from MySQL [webmasterworld.com] msg 9
and see if that gives any hints.
coopster also posted this update which also might help
Export a table to CSV [webmasterworld.com]
I realize these both deal with csv files but the headers may help
I'll let you know if users report any differences. It seems to be more prevalent on dial-up connections.
My feeling is that for whatever reason the client gets confused and doesn't download all of the data.
I'm not sure if that helps but I've tried to send a header that tells the browser how much data should be coming.
I'll let you know how your code fares and if anyone has the cause and solution it would be appreciated :)
......wait one second. The code you gave me consistently does not work so I've gone back to this which seems to work more often than not but still not 100% :(
header("Cache-Control: ");
header("Pragma: ");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$download_name\"");
header("Content-Length: ".$download_size);
header("Accept-Ranges: bytes");
header("Content-Transfer-Encoding: binary");
header('Content-Type: application/octet-stream; name="file.pdf"');
header('Content-Disposition: attachment; filename="file.pdf"');
header('Accept-Ranges: bytes');
header('Pragma: no-cache');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Content-transfer-encoding: binary');
header('Content-length: ' . @filesize('real_file.pdf'));
@readfile('real_file.pdf');