[thelist] PHP Based file download system.

Simon Willison cs1spw at bath.ac.uk
Tue Jul 29 12:59:44 CDT 2003

Hi Tanner,

Tuesday, July 29, 2003, 6:47:39 PM, you wrote:
> I have been charged with designing and implementing a large web based
> file download system.  It needs to restrict users from downloading a 
> file more than once and track some basic usage stats.  This part is easy 
> and I can easily handle.

> My problem is dealing with incomplete downloads.  If a user is only 
> allowed to download a file once, how do I track a completed download?  
> Should I just go with a timestamp based system where a user has X amount 
> of time to get the file?  Any help would be much appreciated.

Unless you are absolutely certain all of your users are on a reliable
broadband connection, a timestamp solution is not a good idea. Since
you are using PHP, a possible solution would be to have a piece of
code at the very end of the script that hands the user the file which
sets a flag in the database to say the download has been completed. I
remember reading somewhere that PHP scripts are aborted if the user
disconnects before the script has fully executed (I can't confirm this
so it is something you would have to check) - if so, the "download
complete" flag would only be set once the user had completed their

Only allowing users to download a file once seems like quite a strange
requirement to me. What if a user downloads the file, then
accidentally deletes it and needs to download it again?



More information about the thelist mailing list