Jump to content

Archived

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

DLR

download file (ebook) to computer

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.

Share this post


Link to post
Share on other sites
Its a bit late here and I'm not that good at all with php, but couldn't you do something like

if ($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?

Share this post


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

Share this post


Link to post
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?

Share this post


Link to post
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.

Share this post


Link to post
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]


Share this post


Link to post
Share on other sites

×

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.