Valhalla Legends Archive

Programming => Web Development => Topic started by: FrostWraith on January 06, 2007, 12:53 PM

Title: [PHP] Checking if User Completed Download
Post by: FrostWraith on January 06, 2007, 12:53 PM
Is there a way to not only check how many users have clicked the download link, but actually know if they finished it or not? (Other than going into the server log)
Title: Re: [PHP] Checking if User Completed Download
Post by: rabbit on January 06, 2007, 03:33 PM
Probably.
Title: Re: [PHP] Checking if User Completed Download
Post by: FrostWraith on January 06, 2007, 11:16 PM
Haha. I would be grateful if someone took the time and explained how this would be done.
Title: Re: [PHP] Checking if User Completed Download
Post by: Arta on January 09, 2007, 06:51 PM
I doubt it. In any event, it's a non-trivial problem, so I doubt anyone will do the research for you! If you find a way, it would be interesting to hear about it.
Title: Re: [PHP] Checking if User Completed Download
Post by: Zorm on January 10, 2007, 10:25 PM
Its probably possible using some combination of fpassthru and connection_aborted. Actually theres a comment in the docs for fpassthru that appear to be capable of doing what you want. http://www.php.net/fpassthru
Title: Re: [PHP] Checking if User Completed Download
Post by: Arta on January 15, 2007, 09:40 AM
Neat :)
Title: Re: [PHP] Checking if User Completed Download
Post by: Ersan on March 18, 2007, 06:56 AM
That will cause more problems than it's worth, trust me - especially for large files.

Use fread instead of fpassthru if this is absolutely necessary:
<?phpwhile (!feof($res)) {$buffer = fread($res, 2048);echo $buffer;$bytessent+=strlen($buffer);}if ($bytessent == filesize($file)) {// File completed downloading.}?>


This will severely impact performance (though not nearly as much as fpassthru) if your website is high-traffic.