Jump to content

download file (ebook) to computer


DLR

Recommended Posts

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.
Link to comment
https://forums.phpfreaks.com/topic/15773-download-file-ebook-to-computer/
Share on other sites

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.php
2) 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.
user that attempt to goto the folder directly ok.

put this inside the folder with the files that are getting downloaded

this will get called first in the folder as it is a index.php file.

index.php
[code]
<?php
header("location: http://your_site_name.php");
?>
[/code]


Archived

This topic is now archived and is closed to further replies.

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