• Welcome to Valhalla Legends Archive.
 

[PHP] Checking if User Completed Download

Started by FrostWraith, January 06, 2007, 12:53 PM

Previous topic - Next topic

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)

rabbit

Grif: Yeah, and the people in the red states are mad because the people in the blue states are mean to them and want them to pay money for roads and schools instead of cool things like NASCAR and shotguns.  Also, there's something about ketchup in there.

FrostWraith

Haha. I would be grateful if someone took the time and explained how this would be done.

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.

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. http://www.php.net/fpassthru
"Now, gentlemen, let us do something today which the world make talk of hereafter."
- Admiral Lord Collingwood

Arta


Ersan

#6
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:
<?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.