note 26414 added to function.fpassthru

From: Date: Wed, 30 Oct 2002 09:51:45 +0000
Subject: note 26414 added to function.fpassthru
Groups: php.notes 
Request: Send a blank email to php-notes+get-38737@lists.php.net to get a copy of this message
This code works fine with a download manager... maybe not the best solution, but the only one that works with IE!!!!! It forces download, but gif file don't want to be downloaded!!! so I need to simply display them in browser... NB $file is the result of a query on the file table... require_once("auth.inc.php"); $attachment = (strstr($HTTP_USER_AGENT, "MSIE")) ? "" : " attachment"; // IE 5.5 fix. //Content of file if (!headers_sent()){ $ficexp=explode('.',$file["orig_name"]); $ext=$ficexp[sizeof($ficexp)-1]; if ($ext!='gif'){ header('Cache-Control: no-cache, must-revalidate'); header('Pragma: no-cache'); header("Content-Type: application/force-download"); header("Content-Length: ".filesize("files/".$file["save_name"])); header("Content-Disposition: ".$attachment."; filename=".$file["orig_name"]); } $fn=fopen("files/".$file["save_name"], "rb"); fpassthru($fn); } else { MessageBox('Headers already sent, cannot force download!'); } Min's -- http://www.php.net/manual/en/function.fpassthru.php http://master.php.net/manage/user-notes.php?action=edit+26414 http://master.php.net/manage/user-notes.php?action=delete+26414 http://master.php.net/manage/user-notes.php?action=reject+26414

« previous php.notes (#38737) next »