views:

126

answers:

2

Hi,

I want to prevent downloading the zip file from my site. Only allowed for some times(at the time of payment). How can it me possible to expire that link or somthing like that to prevent my zip files.

How the rapidshare.com working? we can see the url but not possible to download ??

+1  A: 

look at my answer and the comments on this question http://stackoverflow.com/questions/1467027/what-is-the-best-method-to-hide-a-file-on-a-server/1467154#1467154 .. this is an idea and may work well for u , if u find it interesting and you agree with it

Edit: As for how rapidshare works , i think u can hold the time when u want the actual download to happen in session and disable the link button with javascript on the UI , so even if they find the link and they goto it , you can check the time against the session time and redirect them elsewhere.

Sabeen Malik
once you successfully downloaded that file and copied the url/file path from browser , so next time u can use the same link for downalod. or u can pass to ur friends that to help him!!!! so i want to prevent that kind of activities
coderex
A: 

I am assuming only a registered member can download? You can store the time of payment in a database. Then the download can be accessed through a url like this: http://myhost/download-file.php?file=the-file-name.smthn
When the user goes to this url do all the credential checks like user name and password and the time he has paid. If he is allowed to download fetch the file and output to the browser like so:

$file = file_get_contents('dir-inaccessible-through-web/the-file-name.smthn');
header('Content-disposition: attachment; the-file-name.smthn');
// optionally
$size = strlen($file);
header('Content-length: ' . $size);
echo $file;

Note that the actual file is inaccessible to the web.

andho
Although i don't think this how rapidshar does it.
andho