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

AuthorMessageTime
FrostWraith
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)
January 6, 2007, 6:53 PM
rabbit
Probably.
January 6, 2007, 9:33 PM
FrostWraith
Haha. I would be grateful if someone took the time and explained how this would be done.
January 7, 2007, 5:16 AM
Arta
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 10, 2007, 12:51 AM
zorm
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. [url]http://www.php.net/fpassthru[/url]
January 11, 2007, 4:25 AM
Arta
Neat :)
January 15, 2007, 3:40 PM
Ersan
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:
[code]<?php
while (!feof($res)) {
$buffer = fread($res, 2048);
echo $buffer;
$bytessent+=strlen($buffer);
}
if ($bytessent == filesize($file)) {
// File completed downloading.
}
?>[/code]

This will severely impact performance (though not nearly as much as fpassthru) if your website is high-traffic.
March 18, 2007, 11:56 AM

Search