note 34319 added to function.fread

From: Date: Wed, 23 Jul 2003 20:52:58 +0000
Subject: note 34319 added to function.fread
Groups: php.notes 
Request: Send a blank email to php-notes+get-52517@lists.php.net to get a copy of this message
readfile() cause a lot of problem with IE when trying to 'open' a file while download the file using the header() scripts. I'm using IIS and IE where this problem occur. Instead, the alternative is to use the fopen(), fread(), fclose() and spit out the result. This solve the problem with opening the file while downloading. --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.fread.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34319 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34319&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34319&report=yes

« previous php.notes (#52517) next »