Can I serve MP3 files with PHP?

Your Content-Disposition should be:

header('Content-Disposition: attachment; filename="sometrack.mp3"');

Not sure if that’s the problem though. I would also recommend using readfile to output the file:

readfile($rSong);

Also, it can’t hurt to use an exhaustive Content-Type header, and set the Content-Transfer-Encoding:

header("Content-Transfer-Encoding: binary"); 
header("Content-Type: audio/mpeg, audio/x-mpeg, audio/x-mpeg-3, audio/mpeg3"); 

Leave a Comment