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!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
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;
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Thanks but the code is not working ... all it does is open a pdf and an error occurs mentioning that the file is corrupted but I know that the file is not!!!!