force download

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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--


--
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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux