PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Ignore_User_Abort(True); //necessary to make sure the script finishes running to check for stop
$start_time = time();
// I created a blank file that could be written
$fo = fopen("stream_result.txt", "wb");
fwrite($fo, "started...\n");
fclose($fo);
echo "running";
$previous = 0;
While(!Connection_Aborted()) {
if((time() - $start_time) != $previous) {
echo "."; // print a period every second
$previous++;
}
Flush(); //Now php will check the connection
}
if(connection_status() != 0) {
$fo = fopen("stream_result.txt", "ab");
fwrite($fo, "stopped after ".(time() - $start_time)." seconds\n");
fclose($fo);
}
This will write to a file (that must already be created on the server) the number of seconds the script was running.
My problem is in determining how much of the file has been transfered. I thought I might be able to use ftell($handle) to tell me where the current pointer is in the file transfer, but the value continues to be empty... as if ftell() doesn't work or perhaps I don't really know how to use it.
Basically... in the above script, is there any way to determine how much of the file has been transfered?