Fixing issue where MediaView doesnt properly force download on IE, fixes #6064

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@8040 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2009-02-17 18:23:44 +00:00
parent 93ab1be658
commit 5378c79758

View file

@ -130,13 +130,21 @@ class MediaView extends View {
} }
if ($download) { if ($download) {
$contentType = 'application/octet-stream'; $contentTypes = array('application/octet-stream');
$agent = env('HTTP_USER_AGENT'); $agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) { if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
$contentType = 'application/octetstream'; $contentTypes[0] = 'application/octetstream';
} else if (preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
$contentTypes[0] = 'application/force-download';
array_push($contentTypes, array(
'application/octet-stream',
'application/download'
));
} }
foreach($contentTypes as $contentType) {
header('Content-Type: ' . $contentType); header('Content-Type: ' . $contentType);
}
header('Content-Disposition: attachment; filename="' . $name . '.' . $extension . '";'); header('Content-Disposition: attachment; filename="' . $name . '.' . $extension . '";');
header('Expires: 0'); header('Expires: 0');
header('Accept-Ranges: bytes'); header('Accept-Ranges: bytes');