Download Pdf file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
moeamla
Forum Newbie
Posts: 9
Joined: Mon Oct 29, 2007 10:31 am
Location: Greenville,NC

Download Pdf file

Post 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.....
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Duplicate thread. Locked.
Locked