Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

note 84130 modified in function.filesize by danbrown

0 views
Skip to first unread message

danb...@php.net

unread,
Jan 18, 2009, 12:33:58 PM1/18/09
to php-...@lists.php.net
<?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

)

--was--
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

)

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

0 new messages