Skip to content

Instantly share code, notes, and snippets.

@anton-ryzhov
Created February 1, 2012 07:34
Show Gist options
  • Save anton-ryzhov/1715718 to your computer and use it in GitHub Desktop.
Save anton-ryzhov/1715718 to your computer and use it in GitHub Desktop.
Content-Disposition with encoding fix for Firefox
<?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