get file size of remote url

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;
}

from: http://php.net/manual/en/function.filesize.php

posted @ 2011-11-09 18:36  Lux.Y  阅读(278)  评论(0编辑  收藏  举报