Hello,
I am using the code below to force a file download from a server. This code works well on IE. On Mozilla and Safari browsers, I get
the savefile dialog box, and then click on the save button. Everything seems to go fine but I always get either and empty file or an incomplete download. Would anyone have an idea of the problem?
I
n the exemple below I use a pdf file but the problem does not seem to be related to mime-types since I have tested with different type of files.
Thanks in advance
Markus
<?php
$file_name = "Dirtomyfile/file.pdf";
$file_size = filesize($file_name);
$fp = fopen($file_name, 'rb');
header("Content-Length:.$file_size");
header("Content-transfer-encoding: binary");
header("Content-Type: application/octet-stream");
header("Content-Type: application/pdf");
header("Content-Disposition: attachment; filename=\"" . $file_name ."\"");
header("Connection: close");
header("Cache-Control: no-cache, must-revalidate");
header("Pragma: no-cache");
$content = fread($fp, $file_size);
fclose($fp);
print $content;
exit;
?>