DLR Posted July 27, 2006 Share Posted July 27, 2006 HI,THis one has me beat. I want to have a viewer click a button and then download a file (an ebook) from my domain to their computer. I will protect the download with a password - but what is the command to activate the download?I have searched and searched!Appreciate your help. Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/ Share on other sites More sharing options...
hostfreak Posted July 27, 2006 Share Posted July 27, 2006 Its a bit late here and I'm not that good at all with php, but couldn't you do something likeif ($password == "password") {echo "link to download file";}Then just include a temporaily link to the file download? I'm sure you can expand on that? Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64485 Share on other sites More sharing options...
hostfreak Posted July 27, 2006 Share Posted July 27, 2006 Ah sorry, I think I totally misunderstood your post. Why not just include a link directly to the download in your button? That will intiate the download. Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64488 Share on other sites More sharing options...
DLR Posted July 27, 2006 Author Share Posted July 27, 2006 Hi. If I use this type of code<a Href="file_to_download"><image "button"></a>THe browser simply opens the file.I really want it downloaded a a file - could be .pdf or .cdr file for example.Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64822 Share on other sites More sharing options...
phil.t Posted July 28, 2006 Share Posted July 28, 2006 I think you should be able to accomplish what you're describing by limiting access (via permissions) to the directory containing the file to be downloaded. In both Windows and Linux there are ways of password protecting a web directory such that if a user attempts to access a directory or any file therein, they will be prompted for a username/password.Limitations are that it would be impracticle to have more than one username/password combination for any given directory; and having the password for that directory would allow access to all files in the dirctory (unless file level permissions were set otherwise)... which means if you limited access on a per-user/per-file basis, it could get pretty ugly.You could do something like this:1) Have a form with a password field, and a button, with action to verify.php2) In verify.php, verify the validity of the password... if it's correct redirect the user to the download location (using the header('Location: ' , $url) function) and redirect them to an error message otherwise.Once they download once, though, they will know the location of the url. If they didn't get the password right, the location is still unknown to them and they'd have to guess. Using this approach with good file/directory naming could be effective.Hope this helps. Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64954 Share on other sites More sharing options...
redarrow Posted July 28, 2006 Share Posted July 28, 2006 user that attempt to goto the folder directly ok.put this inside the folder with the files that are getting downloadedthis will get called first in the folder as it is a index.php file.index.php[code]<?phpheader("location: http://your_site_name.php");?>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64963 Share on other sites More sharing options...
legohead6 Posted July 28, 2006 Share Posted July 28, 2006 go to the code recipretory ... hteres a force download code! try that Quote Link to comment https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/#findComment-64969 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.