Aye. Frustrating.
The code below creates a file, fills it with m3u playlist info, and is supposed to send it off to the user. The 'Content-Disposition' header pops up the 'Open/Save/Etc' dialogue box, for the user can save/open the m3u file.
The problem I'm having is that instead of sending the generated m3u file, it's sending the html output for the entire page.
I've verified that the m3u file is getting generated and written to properly.
Any ideas? I'm thinking the problem is either the mime type is incorrect*, or i'm making some other bonehead mistake.
*Note: I've tried all the following as mime types, to no avail:
- audio/mpegurl
- audio/x-mpegurl
- audio/m3u
- audio/x-m3u
CODE
// these are sent via GET, but for simplicity...
$play="songname.mp3";
$where="path/to/mp3";
$mp3www="www.myserver.com/mp3archive/";
if(isset($play) && $play!="" && isset($where)){
$file=explode(".",$play);
$name="/tmp/".time().".".$file[0].".m3u";
$temp=fopen($name,"a+");
fwrite($temp, "#EXTM3U \n #EXTINF:-1, $where --> $play || Half-assed Notnull Streaming by RoG || \n ".$mp3www.$where."/".$play."\n");
fclose($temp);
header("Content-type: audio/mpegurl");
header("Content-Disposition: attachment; filename=$file[0].m3u");
fpassthru(fopen($name,"rb"));
}
END CODE
TIA for any help ;-)
-Paul