note 81925 added to function.readfile
| From: | marro at email dot cz | Date: | Wed, 19 Mar 2008 19:17:15 +0000 |
| Subject: | note 81925 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-137206@lists.php.net to get a copy of this message | ||
My script working correctly on IE6 and Firefox 2 with any typ e of files (I hope :))
function DownloadFile($file) { // $file = include path
if(file_exists($file)) {
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Disposition: attachment; filename='.basename($file));
header('Content-Transfer-Encoding: binary');
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Pragma: public');
header('Content-Length: ' . filesize($file));
ob_clean();
flush();
readfile($file);
exit;
}
}
Run on Apache 2 (WIN32) PHP5
----
Server IP: 212.24.129.51
Probable Submitter: 81.91.213.250
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- https://master.php.net/note/edit/81925
Del: integrated -- https://master.php.net/note/delete/81925/integrated
Del: useless -- https://master.php.net/note/delete/81925/useless
Del: bad code -- https://master.php.net/note/delete/81925/bad+code
Del: spam -- https://master.php.net/note/delete/81925/spam
Del: non-english -- https://master.php.net/note/delete/81925/non-english
Del: in docs -- https://master.php.net/note/delete/81925/in+docs
Del: other reasons-- https://master.php.net/note/delete/81925
Reject -- https://master.php.net/note/reject/81925
Search -- https://master.php.net/manage/user-notes.php