Downloading a PDF sile from server

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

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

Downloading a PDF sile from server

Post by moeamla »

Hey all,

Im trying to download and open (an existing pdf file on the server) on the user's pc and I have this code but it is not

WORKING!! I read a lot and nothing working

Im using PHP5 and apache

here is the code:
//$file is the path of the file on the server
//$filename is the file name
//$filesize is size


$filename=substr($file,20);
$filesize=filesize($file);
header("Content-Disposition: attachment; filename=".$filename);
header("Content-type: application/pdf");
header("Content-Length: ".$filesize);
$data = file_get_contents($file);
echo $data;



NEED HELP!! PLEASE!!
Post Reply