How to output an MP3 file?

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

 



I'm trying to route all my MP3 requests through a brief PHP script to log the downloads to a database, and then I want to output the MP3 exactly as if the browser had requested it normally. So far I haven't found headers that will serve it normally; it either wants to download it as an attachment or an application. I want the browsers to treat it however they normally treat MP3's, usually playing in the browser window. Here's what I'm doing:

(my MP3 files are all named podcast-xxxx.mp3) where $id is the xxx:

header('Content-Type: application/octet-stream');		
header('Content-Disposition: attachment; filename=podcast-'.$id.'.mp3');
$size = filesize('audio/podcast-'.$id.'.mp3');
header('Content-Length: '.$size);
readfile('audio/podcast-'.$id.'.mp3');

What should I change?

- Brian

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