note 36554 deleted from function.header by victor
| From: | victor@php.net | Date: | Sat, 19 Jun 2004 15:34:20 +0000 |
| Subject: | note 36554 deleted from function.header by victor | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-71359@lists.php.net to get a copy of this message | ||
Note Submitter:
----
Some browsers out there on the Internet act funny, especially with Internet Explorer (IE), so this
script will help. This is ony an example for displaying the PDF. You can REM out the code and
change it to make it be a downloadable file instead.
--snip--
<?
$filename=$_REQUEST['PDF_FileName'];
$filepath=$_REQUEST['PDF_FilePath'];
$filesize=filesize($filepath);
header("Pragma: public");
header("Expires: 0"); // set expiration time
header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
header("Content-Type: application/pdf");
header("Content-Length: ".$filesize);
header("Content-Disposition: inline; filename=$filename");
header("Content-Transfer-Encoding: binary");
//Can't use readfile() due to poor controlling of the file download.
//(IE have this problems)...
//readfile($filepath);
//use fopen() instead of readfile...
$fp = fopen($filepath, 'rb');
$pdf_buffer = fread($fp, $filesize);
fclose ($fp);
//sleep(1);
print $pdf_buffer;
//Required, to keep IE from running into problems
//when opening the file while downloading or downloading...
//(IE been acting strange lately...)
exit();
?>
--snip--