Page 1 of 1

Download Pdf file

Posted: Tue Nov 20, 2007 10:41 am
by moeamla
Hello again,

I have this code to download a pdf file ... It does open a pdf file but an error message shows indicating the information is corrupted or that it has been sent as a email attachment!!!!!!

I researched everywhere and I got the same answer..

Here is the code:

$filesize=filesize($file);


$mm_type="application/pdf";
header("Content-Type: " . $mm_type);
header("Content-Length: " .$filesize );
header('Content-Disposition: attachment; filename="'.basename($file,".pdf").'"');
readfile($filename);



Or

$tmp = file_get_contents($file);
header('Content-type: application/pdf');
header("Content-Length: ".$filesize);
header('Content-Disposition: attachment; filename="'.$filaname.'"');
echo $tmp;



Please Need Help ASAP.....

Posted: Tue Nov 20, 2007 11:28 am
by John Cartwright
Duplicate thread. Locked.