protecting mp3's - follow up

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I have made some progress regarding my previous post. I have public_html and  
audio as folders at the same level. I am trying to allow visitors to stream  
the audio in the audio folder using the following:

 $link = "../audio/".$file;

  $handle = fopen($link, 'r');

  header("Content-type: audio/mp3");

I get a valid handle but the fpassthru does not work properly. Media Player  
launches, hangs for a while then says it reached the end of the file. No  
audio plays.

Any ideas?



Re: protecting mp3's - follow up

I have since learned that the proper way to stream is to create an m3u file  
which will cause the default browser to stream the mp3. But my audio files  
are external to the web dir. And I simply can not get fpassthru to work.



Re: protecting mp3's - follow up

Quoted text here. Click to load it

You may need to open the file in binary mode as well:


or check into the 'readfile()' function as you need no fopen() to dump the
file to the client...

FREE Avatar hosting at

Site Timeline