note 54350 modified in function.fread by danbrown

From: Date: Fri, 06 Jan 2012 21:10:30 +0000
Subject: note 54350 modified in function.fread by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-185436@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 <?php # 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"); } ?> --was-- 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"); } ?> http://php.net/manual/en/function.fread.php

« previous php.notes (#185436) next »