I've modified the example given by straz at -removethispart-mac dot com to count each byte of the file out. This can then be compared with the filesize once the file sending is complete to determine whether the file was sent succesfully or not.
Of course, this doesn't guarantee that the user actually recieved the file successfully though will let us know if something goes wrong half way through reading/sending the file at our end.
<?
/* fpassthru is apparantly a memory-hog. Use this instead */
while(!feof($fp)) {
$buf = fread($fp, 4096);
echo $buf;
$bytesSent+=strlen($buf); /* We know how many bytes were sent to the user */
}
?>
I've then got this code to update my database to say that the file was downloaded successfully.
<?
if($bytesSent==filesize($file)) {
/* Do some cool stuff here! */
}
?>