hassank1 Posted January 22, 2012 Share Posted January 22, 2012 Hi I am creating an e-commerce website, where users who pay with their credit card are able to download pdf books. how can I make a PDF file only accessible for those users (who pay and validate their credit card) and not for everyone ? I want to know the main idea about securing these files. Link to comment https://forums.phpfreaks.com/topic/255555-only-allow-downloading-files-for-users-who-pay/ Share on other sites More sharing options...
joel24 Posted January 23, 2012 Share Posted January 23, 2012 have a database with the file locations, store the files in a folder with permissions restricting public access.. then retrieve the file with PHP (after fetching the location from the mysql database) header("Content-type: application/force-download"); header("Content-Transfer-Encoding: Binary"); header("Content-length: ".filesize($file)); header("Content-disposition: attachment; filename=".basename($file)); readfile("$file"); Link to comment https://forums.phpfreaks.com/topic/255555-only-allow-downloading-files-for-users-who-pay/#findComment-1310193 Share on other sites More sharing options...
jcbones Posted January 23, 2012 Share Posted January 23, 2012 store the files in a folder with permissions restricting public access.. or, above the public directory. Link to comment https://forums.phpfreaks.com/topic/255555-only-allow-downloading-files-for-users-who-pay/#findComment-1310204 Share on other sites More sharing options...
hassank1 Posted January 23, 2012 Author Share Posted January 23, 2012 that's what I was looking for , thanks. Link to comment https://forums.phpfreaks.com/topic/255555-only-allow-downloading-files-for-users-who-pay/#findComment-1310237 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.