note 27809 added to function.header
| From: | revol at post dot sk | Date: | Thu, 19 Dec 2002 14:38:20 +0000 |
| Subject: | note 27809 added to function.header | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-41121@lists.php.net to get a copy of this message | ||
If You want to download a file from the server, the best way which I have found is the following:
list($adrs,$name)=explode("/",$file);
header('Content-Type: ' . $mimetypes[substr(strrchr($file, '.'), 1)]);
header ("Content-Disposition: attachment; filename=$name");
header ("Cache-control: private");
$fp = fopen('../files/'.$file, 'r');
fpassthru($fp);
Do not use "fclose($fp);", it will return You a string which will be writed to the end of
the file and that can made some troubles if You are downloading for example a word doc.
Anyway, the function "fpassthru($fp);" will close the connection, so there is no reason to
use fclose();
--
http://www.php.net/manual/en/function.header.php
http://master.php.net/manage/user-notes.php?action=edit+27809
http://master.php.net/manage/user-notes.php?action=delete+27809
http://master.php.net/manage/user-notes.php?action=reject+27809