note 72545 deleted from function.header by tularis
| From: | tularis@php.net | Date: | Fri, 20 Apr 2007 14:14:58 +0000 |
| Subject: | note 72545 deleted from function.header by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-125625@lists.php.net to get a copy of this message | ||
Note Submitter: sarimarton at gmail dot com
----
Filenames in the browser's download dialog can be a bit problematic, when it contains spaces or
non-ASCII characters. To set the appropriate cross-browser header, use the following code. It is
assumed that the script receives a query like this: download.php?source=/content/példa
fájl.doc
<?php
$filename = basename($_GET['source']);
$ie = eregi("msie", $_SERVER['HTTP_USER_AGENT']);
if ($ie) $filename = rawurlencode($filename);
/* ... */
header("Content-Disposition: attachment; filename=\"$filename\"");
?>