note 31899 added to function.fpassthru
| From: | DarkAngela_ at hotmail dot com | Date: | Thu, 08 May 2003 09:48:49 +0000 |
| Subject: | note 31899 added to function.fpassthru | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-47683@lists.php.net to get a copy of this message | ||
Just a little thing more from the ssharma's script (thx to him for his great help ...) :
Don't forget to put the fopen with the "rb" argument and not just with the
"r"
or you won't be able to make the script work with all pdf file.
My final script (working for Open and Save on a 1.9 Mb complex PDF file) :
<?php
//The filename is stored in the $produitFilename variable in my script (the only thing you need)
// You need to specify the REAL path for your file and not the URL
$fullPath = getcwd()."./directory_where_the_file_is/".$produitFilename;
if ($fd = fopen ($fullPath, "rb")) {
$fsize =filesize($fullPath);
$fname = basename ($fullPath);
header("Pragma: ");
header("Cache-Control: ");
header("Content-type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"".$fname."\"");
header("Content-length: $fsize");
fpassthru($fd);
}
?>
Have fun and thx u all 4 ur great help ...
Simon (from Paris - France)
--
http://www.php.net/manual/en/function.fpassthru.php
http://master.php.net/manage/user-notes.php?action=edit+31899
http://master.php.net/manage/user-notes.php?action=delete+31899
http://master.php.net/manage/user-notes.php?action=reject+31899