note 36554 added to function.header

From: Date: Tue, 14 Oct 2003 18:57:40 +0000
Subject: note 36554 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-58588@lists.php.net to get a copy of this message
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-- ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+36554 Delete -- http://master.php.net/manage/user-notes.php?action=delete+36554&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+36554&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#58588) next »