Hi. At the moment I'm using something similar to the following code to download mp3s:
header("Content-type: audio/x-mp3");
header("Content-Disposition: attachment; filename=$file.mp3");
readfile("$file.mp3");
This works fine, but I have a problem if I want to password-protect the mp3s. If the php script is in the same directory as the mp3 (i.e. the password-protected directory), there's no problem, as only people with access to that directory can run it. If the php script is in a non-protected directory however, there is a problem, as anyone can run it - and download the mp3 by doing so.
What I want to know is if the above code can be extended in such a way as to prevent anyone and everyone from downloading the mp3. I don't want to put the script in the same directory as the file unless I really have to.
I've tried adding:
header("Content-location: $collection/");
but, unlike header("Location: $collection") - which I don't want because I don't want to redirect people - this doesn't prompt for username and password. Can anyone help?