Created
February 1, 2012 07:34
-
-
Save anton-ryzhov/1715718 to your computer and use it in GitHub Desktop.
Content-Disposition with encoding fix for Firefox
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function contentDispose($type, $name=null) | |
{ | |
$header=$type; | |
if ($name) | |
{ | |
// Firefox bug https://bugzilla.mozilla.org/show_bug.cgi?id=588409 | |
$isFF=(strpos(strtolower($_SERVER['HTTP_USER_AGENT']), 'firefox') !== false); | |
$name=$isFF ? sprintf('=?utf-8?B?%s?=', base64_encode($name)) : strtr(urlencode($name), array('+'=> '%20')); | |
$header.=sprintf('; filename="%s"', $name); | |
} | |
$this->addHttpMeta('Content-Disposition', $header); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment