James R. wrote:
That would be browser dependent, something you have no control over.
Maybe you can include a little text message saying "right-click save
as" for the users not intelligent enough to figure it out themselves.
----- Original Message ----- From: "Sebastian"
<sebastian@xxxxxxxxxxxxxxxxxxx>
To: <php-general@xxxxxxxxxxxxx>
Sent: Wednesday, August 10, 2005 12:00 PM
Subject: force download
some of my users are complaining that when they try download media
files (mp3, mpeg, etc) their media player opens and doesn't allow
them to physically download the media. These are IE users, firefox
seems to like my code, but IE refuses to download the file and plays
it instead..
can anyone view my code and see how i can force media file downloads
on IE?
--snip--
header('Cache-control: max-age=31536000');
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + 31536000) . '
GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $file['date']) .
' GMT');
if ($extension != 'txt')
{
header("Content-disposition: inline; filename=\"$file[type]\"");
}
else
{
// force txt files to prevent XSS
header("Content-disposition: attachment; filename=\"$file[type]\"");
}
header('Content-Length: ' . $file['size']);
switch($extension)
{
case 'zip':
$headertype = 'application/zip';
break;
case 'exe':
$headertype = 'application/octet-stream';
break;
case 'mp3':
$headertype = 'audio/mpeg';
break;
case 'wav':
$headertype = 'audio/wav';
break;
case 'mpg':
$headertype = 'video/mpeg';
break;
case 'avi':
$headertype = 'video/avi';
break;
default:
$headertype = 'unknown/unknown';
}
header('Content-type: ' . $headertype);
--/snip--
forgot to mention, they can't right click to "save as" because if you
notice from my code i am pushing the file to them... without an actual
path to the file. so if they did do a "save as" it'll just save the
php/html output, which will be blank in this case.
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.338 / Virus Database: 267.10.5/67 - Release Date: 8/9/2005
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php