git-svn-id: file:///svn/phpbb/trunk@6523 89ea8834-ac86-4346-8a33-228a782c2dd0
This commit is contained in:
David M 2006-10-23 21:07:45 +00:00
parent 74e03ddf62
commit a0201b4958

View file

@ -232,8 +232,8 @@ function send_file_to_browser($attachment, $upload_dir, $category)
}
// Send out the Headers. Do not set Content-Disposition to inline please, it is a security measure for users using the Internet Explorer.
header('Content-Type: ' . $attachment['mimetype'] . '; name="' . $attachment['real_filename'] . '"');
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; filename="' . $attachment['real_filename'] . '"');
header('Content-Type: ' . $attachment['mimetype']);
header('Content-Disposition: ' . ((strpos($attachment['mimetype'], 'image') === 0) ? 'inline' : 'attachment') . '; ' . header_filename($attachment['real_filename']));
if ($size)
{
@ -247,6 +247,23 @@ function send_file_to_browser($attachment, $upload_dir, $category)
exit;
}
/*
* Get a browser friendly UTF-8 encoded filename
*/
function header_filename($file)
{
// There be dragons here...
// IE follows no RFC, follow the RFC for extended filename for the rest
if (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)
{
return "filename=" . rawurlencode($file);
}
else
{
return "filename*=UTF-8''" . rawurlencode($file);
}
}
/**
* Check if downloading item is allowed
*/