serving files outside webroot and http headers help
Posted: Sat Apr 21, 2007 10:00 am
Weirdan | Please use
thats the only code I have in the php file and when i point the browser to the php file, it downloads the php file. when i open the php file i see a bunch of jibberish.
any help would be much appreciated. thanks
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi,
I want to keep mp3 files away from the public but allow them to download the mp3 files if they are members to my site. They can also listen to the mp3 files through an embedded media player on the site and if they wanted to, they can download via a php script.
in the embedded script I point the src to the mp3 file as /home/me/mp3/example.mp3 and it works.
My problem is how to make the file accessible when the user trys to file. I am using the follwing code for testing purposes:Code: Select all
<?
$file = @file_get_contents("/home/me/example.mp3");
if($file != false){
header('Content-Type: application/octet-stream');
echo $file; }
?>any help would be much appreciated. thanks
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]