Alexandru_mbm Posted October 13, 2007 Share Posted October 13, 2007 Hello to you all! This is my first post on this big big forum! Nice one! Let's go directly to the problem... I have an website that has few informations about a process or a product. In this page there is an PDF file that has the hole description and details about that process or product. All i want is that the visitors to register into my website and after that thei can download any PDF file (or other) as much as thei want. I have found some samples on the internet but is only for authentication not for download too. Anyone can help me with this problem ? Please!!! (sorry for my bad english) Link to comment https://forums.phpfreaks.com/topic/73120-download-file-after-authentication/ Share on other sites More sharing options...
[email protected] Posted October 13, 2007 Share Posted October 13, 2007 you can link to the download as download.php?file=1 and then in that you can have: $registered = $_SESSION['logged_in']?true:false; // replace with actual login sequence data if(!$registered) die("message to be displayed if not registered"); $fileid = $_GET['file']; switch($fileid) { case 1: $file = "somefile1.pdf"; break; case 1: $file = "somefile2.pdf"; break; // ...etc default: die("message if file does not exist"); break; // if file ID is not in switch } 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); (untested but should work) Link to comment https://forums.phpfreaks.com/topic/73120-download-file-after-authentication/#findComment-368740 Share on other sites More sharing options...
Alexandru_mbm Posted October 13, 2007 Author Share Posted October 13, 2007 Thanks for your quick reply JustinMs66@hotmail... I'll try it! Link to comment https://forums.phpfreaks.com/topic/73120-download-file-after-authentication/#findComment-368742 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.