Jump to content

Undownloadable content


Go to solution Solved by requinix,

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?

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

  • Solution

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!

Edited by Manixat
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.