|
|
php protecting downloads/music
|
|
|
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
i know there is a way but my google searches don't turn up much useful information.
how would i use php to do downloads? like someone goes to mysite.com/downloads?file=CoolFile.zip
it will download the CoolFile.zip out of mysite/PA3RPY3KN/CoolFile.zip but the url that downloaded from will not show the real directory path.
Also is there a way to protect music this way though php? i want to add some music to some of my pages but just using plain html coding or the little harder javascripting encoding is not what i want to do.
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
Originally Posted by jay3ld
i know there is a way but my google searches don't turn up much useful information.
how would i use php to do downloads? like someone goes to mysite.com/downloads?file=CoolFile.zip
it will download the CoolFile.zip out of mysite/PA3RPY3KN/CoolFile.zip but the url that downloaded from will not show the real directory path.
Also is there a way to protect music this way though php? i want to add some music to some of my pages but just using plain html coding or the little harder javascripting encoding is not what i want to do.
What you're going to want to do is look up the header function on PHP.net. Here's how you download a PDf for example:
Code:
<?php
// We'll be outputting a PDF
header('Content-type: application/pdf');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="downloaded.pdf"');
// The PDF source is in original.pdf
readfile('original.pdf');
?>
(from php.net)
You can perform other steps before initiating the download such as verifying a user session, etc. Just make sure to place the files in a non-web-accessible location and you should be good to go.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
|
|
|
|
|
|
|
Senior User
Join Date: Jul 2004
Status:
Offline
|
|
ahh so mp3 would follow
Code:
<?php
// We'll be outputting a PDF
header('Content-type: application/mp3');
// It will be called downloaded.pdf
header('Content-Disposition: attachment; filename="Sone Name.mp3"');
// The PDF source is in original.pdf
readfile('Songname.mp3');
?>
then in the page i do
Code:
<embed src="music.php" autostart="True" loop="True"></embed>
|
|
|
|
|
|
|
|
|
Senior User
Join Date: Mar 2002
Location: Chicago, IL
Status:
Offline
|
|
I would try it but I think that looks right. To be honest I'm really not up on my EMBED tags these days.
|
We need less Democrats and Republicans, and more people that think for themselves.
infinite expanse
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Forum Rules
|
|
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is Off
|
|
|
|
|
|
|
|
|
|
|
|