Manixat Posted March 20, 2013 Share Posted March 20, 2013 (edited) 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 March 20, 2013 by Manixat Quote Link to comment https://forums.phpfreaks.com/topic/275932-undownloadable-content/ Share on other sites More sharing options...
Solution requinix Posted March 20, 2013 Solution Share Posted March 20, 2013 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); Quote Link to comment https://forums.phpfreaks.com/topic/275932-undownloadable-content/#findComment-1419880 Share on other sites More sharing options...
Manixat Posted March 20, 2013 Author Share Posted March 20, 2013 (edited) 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 March 20, 2013 by Manixat Quote Link to comment https://forums.phpfreaks.com/topic/275932-undownloadable-content/#findComment-1419882 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.