Click to See Complete Forum and Search --> : How to output binary data to browser


sphoenixee
08-17-2008, 05:26 PM
I would like to load binary data and output it to browser.

For example, I have a sound file I want people to download. How do I use PHP to do this?

Doing: $audio=fopen('01 CD Track 01.mp3','rb');

header('Content-Type: audio/mpeg3');

echo $audio;

just prints the resource id#.

I do not want to use html because I want to use PHP to control access to the sound.

Thanks.

sphoenixee

NogDog
08-17-2008, 07:00 PM
<?php
header('Content-Type: audio/mpeg3');
readfile('01 CD Track 01.mp3');
exit();
?>