|
Posted by Jasen Betts on 02/11/06 21:58
On 2006-02-11, Nicholas Sherlock <N.sherlock@gmail.com> wrote:
> Hey all,
>
> People on my website register to be allowed access to certain downloads.
> I store these files above the document root so that they can't be
> accessed by Apache (Only from PHP). I wrote a file serving script which
> dumps the correct headers for the download and calls readfile().
>
> I thought everything was going swimmingly until I realized that my
> webhost has Safe Mode turned on, and the script execution time is
> limited to 30 seconds. If your file takes longer than that to download,
> then too bad :).
>
> So how can I do this? The files that I am serving are no larger than
> about 2 megabytes.
>
> It seems that one option would be to make a copy of the file I want to
> serve, but below the document root so that it is available from the
> browser.
if it's a *nix server make a link instread of a copy of the file it's much
faster, and uses much less disk space.
> I'd give the file a randomly generated name that couldn't just
> be guessed, and just write a regular link to the browser. Has anyone
> tried this, and did it work out okay for you? How did you go about
> cleaning up files after the client has downloaded them? Is there a
> better option?
Store the names and delete any that have been sitting there for more than 30
seconds, or spawn a background script that sleeps for 30 seconds and then
deletes the copy.
With unix the download will continue even after the file is no longer present
windows will ( I think) give an error and not delete the file so you'd have
to find a way to detect that, sleep again, and retry.
Bye.
Jasen
Navigation:
[Reply to this message]
|