<?php
function getSizeFile($url) {
if (substr($url,0,4)=='http') {
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
if ( strcasecmp($x[0], 'HTTP/1.1 200 OK') != 0 ) { $x = $x['content-length'][1]; }
else { $x = $x['content-length']; }
}
else { $x = @filesize($url); }
return $x;
}
?>
In case of you have a redirection in the server (like Redirect Permanent in the .htaccess)
In this case we have for exemple:
[content-length] => Array
(
[0] => 294 // Size requested file
[1] => 357556 // Real Size redirected file
)