note 27809 deleted from function.header by sniper

From: Date: Sun, 07 Sep 2003 21:38:30 +0000
Subject: note 27809 deleted from function.header by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-55633@lists.php.net to get a copy of this message
Note Submitter: revol@post.sk ---- 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();

« previous php.notes (#55633) next »