Valhalla Legends Forums Archive | Web Development | [PHP] Checking if User Completed Download

AuthorMessageTime
FrostWraithIs 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)January 06, 2007, 12:53 PM
rabbitProbably.January 06, 2007, 03:33 PM
FrostWraithHaha. I would be grateful if someone took the time and explained how this would be done.January 06, 2007, 11:16 PM
Arta[vL]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.January 09, 2007, 06:51 PM
ZormIts 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/fpassthruJanuary 10, 2007, 10:25 PM
Arta[vL]Neat SmileyJanuary 15, 2007, 09:40 AM
ErsanThat will cause more problems than it's worth, trust me - especially for large files.

Use fread instead of fpassthru if this is absolutely necessary:
Code:
<?php
while (!feof($res)) {
$buffer fread($res2048);
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.
March 18, 2007, 06:56 AM