Skip to content

Instantly share code, notes, and snippets.

@maxkostinevich
Created January 4, 2016 17:02
Show Gist options
  • Save maxkostinevich/76d488814a6a7cc8222b to your computer and use it in GitHub Desktop.
Save maxkostinevich/76d488814a6a7cc8222b to your computer and use it in GitHub Desktop.
PHP: Determine how many bytes sent over http
<?php
// Determine how many bytes sent over http
ignore_user_abort(true);
$handle = fopen($file_path, 'r');
while ( ! feof($handle)) {
echo fread($handle, 4096);
if (connection_aborted()) {
$transfer_success = false;
$bytes_transferred = ftell($handle);
break;
}
}
fclose($handle);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment