note 69764 deleted from function.readfile by bobby
| From: | bobby@php.net | Date: | Wed, 20 Sep 2006 15:13:10 +0000 |
| Subject: | note 69764 deleted from function.readfile by bobby | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-117351@lists.php.net to get a copy of this message | ||
Note Submitter: knightmb at knightmb dot dyndns dot org
Reason: bad code
----
This is needed to upload a file to the user when the file name has characters like a " or : and
other strange ones in the file name. Otherwise, the file gets cut off and you get the first word in
the filename and nothing more (very confusing). Basically you use the "addslashses"
function just like you would for a database entry, except this is needed for the file as well. Might
be good practice to do this to every file just in case someone has an odd named one.
$filename = "/var/www/Tom J , EdD - Part 2: Response- from "Controlling"
Stress.mp3"
header('Content-Description: File Transfer');
header('Content-Type: application/octet-stream');
header('Content-Length: ' . filesize($filename));
header('Content-Disposition: attachment; filename="' .
addslashes(basename($filename)) . '"');
readfile($filename);