note 87449 added to function.header

From: Date: Fri, 05 Dec 2008 13:46:41 +0000
Subject: note 87449 added to function.header
Groups: php.notes 
Request: Send a blank email to php-notes+get-147707@lists.php.net to get a copy of this message
If using the 'header' function for the downloading of files, especially if you're passing the filename as a variable, remember to surround the filename with double quotes, otherwise you'll have problems in Firefox as soon as there's a space in the filename. So instead of typing: <?php header("Content-Disposition: attachment; filename=" . basename($filename)); ?> you should type: <?php header("Content-Disposition: attachment; filename=\"" . basename($filename) . "\""); ?> If you don't do this then when the user clicks on the link for a file named "Example file with spaces.txt", then Firefox's Save As dialog box will give it the name "Example", and it will have no extension. See the page called "Filenames_with_spaces_are_truncated_upon_download" at http://kb.mozillazine.org/ for more information. (Sorry, the site won't let me post such a long link...) ---- Server IP: 89.31.146.176 Probable Submitter: 130.79.66.229 ---- Manual Page -- http://www.php.net/manual/en/function.header.php Edit -- https://master.php.net/note/edit/87449 Del: integrated -- https://master.php.net/note/delete/87449/integrated Del: useless -- https://master.php.net/note/delete/87449/useless Del: bad code -- https://master.php.net/note/delete/87449/bad+code Del: spam -- https://master.php.net/note/delete/87449/spam Del: non-english -- https://master.php.net/note/delete/87449/non-english Del: in docs -- https://master.php.net/note/delete/87449/in+docs Del: other reasons-- https://master.php.net/note/delete/87449 Reject -- https://master.php.net/note/reject/87449 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147707) next »