note 54350 added to function.fread
| From: | RichardDalerichard at premiumdata dot n dot e dot t | Date: | Fri, 01 Jul 2005 04:11:10 +0000 |
| Subject: | note 54350 added to function.fread | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-91232@lists.php.net to get a copy of this message | ||
If you use any of the above code for downloadinng files, Internet Explorer will change the filename
if it has multiple periods in it to something with square brackets. To work around this, we check
to see if the User Agent contains MSIE and rewrite the necessary periods as %2E
<?
# eg. $filename="setup.abc.exe";
if (strstr($_SERVER['HTTP_USER_AGENT'], "MSIE")) {
# workaround for IE filename bug with multiple periods / multiple dots in filename
# that adds square brackets to filename - eg. setup.abc.exe becomes setup[1].abc.exe
$iefilename = preg_replace('/\./', '%2e', $filename, substr_count($filename,
'.') - 1);
header("Content-Disposition: attachment; filename=$iefilename" );
} else {
header("Content-Disposition: attachment; filename=$filename");
}
?>
----
Manual Page -- http://www.php.net/manual/en/function.fread.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+54350
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes&reason=useless
Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes&reason=non-english
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+54350&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+54350&report=yes
Search -- http://master.php.net/manage/user-notes.php