note 69764 added to function.readfile
| From: | knightmb at knightmb dot dyndns dot org | Date: | Wed, 20 Sep 2006 04:13:36 +0000 |
| Subject: | note 69764 added to function.readfile | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-117336@lists.php.net to get a copy of this message | ||
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);
----
Server IP: 64.71.164.2
Probable Submitter: 69.17.124.192
----
Manual Page -- http://www.php.net/manual/en/function.readfile.php
Edit -- https://master.php.net/note/edit/69764
Del: integrated -- https://master.php.net/note/delete/69764/integrated
Del: useless -- https://master.php.net/note/delete/69764/useless
Del: bad code -- https://master.php.net/note/delete/69764/bad+code
Del: spam -- https://master.php.net/note/delete/69764/spam
Del: non-english -- https://master.php.net/note/delete/69764/non-english
Del: in docs -- https://master.php.net/note/delete/69764/in+docs
Del: other reasons-- https://master.php.net/note/delete/69764
Reject -- https://master.php.net/note/reject/69764
Search -- https://master.php.net/manage/user-notes.php