note 34320 added to function.header

From: Date: Wed, 23 Jul 2003 20:55:09 +0000
Subject: note 34320 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-52518@lists.php.net to get a copy of this message
Trying to use readfile() along with the header() for downloading the file. It work fine for downloading. But with opening the file while downloading for IE, it blow up. So, instead of using the readfile(), use fopen, fread, fclose instead and this fix the problem for IE. --snip-- $file="test.exe"; header ("Pragma: public"); header ("Expires: 0"); // set expiration time header ("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header ("Content-Type: application/force-download"); header ("Content-Type: application/octet-stream"); header ("Content-Type: application/download"); header ("Content-Disposition: attachment; filename=test_different_name.exe;"); header ("Content-Length: ".filesize($file)); header ("Content-Transfer-Encoding: binary"); //readfile($file); //$content = fread ($fp, filesize($file)); //fclose ($fp); //print $content; $fp = fopen($file, 'rb'); $content = fread ($fp, filesize($file)); fclose ($fp); print $content; exit(); --snip-- ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34320 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34320&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34320&report=yes

« previous php.notes (#52518) next »