Jump to content

Undownloadable content


Manixat

Recommended Posts

Hello freaks,

 

I have a section of my site where users can download certain files if they have paid their members fee. But the problem is that when a user pays the fee and downloads a file, he can see it's absolute location and can easily send it ( the link ) to other people. Is there any way of preventing this?

Link to comment
https://forums.phpfreaks.com/topic/275932-undownloadable-content/
Share on other sites

Make the download go through a PHP script instead of going directly to the file. That script checks if the user has paid and only outputs the file if they have.

 

The "outputs the file" bit might look like

header("Content-Disposition: attachment; filename=\"the name of the file.ext\"");
header("Content-Type: application/octet-stream");
readfile($filename);

Well that's obvious but when a user has paid and has downloaded a file then he can see the absolute path to the file in his browser downloads history, then he can send the link to, say, his friend and the friend can directly download the file without going through the script. 

I thought of creating temporary files that are to be downloaded, but that is going to be inconvenient with a lot of requests, having the server copy files of over 15mb and all... :/

 

 

 

EDIT: Or not, I actually commented before trying out the code with the headers you suggested and I'm terribly sorry as well as terribly grateful as that was exactly what I needed.

Thank you!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.