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
Share on other sites

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?
Link to comment
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.
Link to comment
Share on other sites

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]


Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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