mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
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:
parent
93ab1be658
commit
5378c79758
1 changed files with 13 additions and 5 deletions
|
@ -130,13 +130,21 @@ class MediaView extends View {
|
|||
}
|
||||
|
||||
if ($download) {
|
||||
$contentType = 'application/octet-stream';
|
||||
$contentTypes = array('application/octet-stream');
|
||||
$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)) {
|
||||
$contentType = 'application/octetstream';
|
||||
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent)) {
|
||||
$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-Disposition: attachment; filename="' . $name . '.' . $extension . '";');
|
||||
header('Expires: 0');
|
||||
header('Accept-Ranges: bytes');
|
||||
|
|
Loading…
Reference in a new issue