note 81906 deleted from function.filesize by aidan
| From: | aidan@php.net | Date: | Sat, 02 May 2009 11:15:58 +0000 |
| Subject: | note 81906 deleted from function.filesize by aidan | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-154112@lists.php.net to get a copy of this message | ||
Note Submitter: bifor at free dot fr
----
A simple function for return the length of a link, or a file.
<?php
function urlfilesize($url,$thereturn) {
if (substr($url,0,4)=='http') {
$x = array_change_key_case(get_headers($url, 1),CASE_LOWER);
$x = $x['content-length'];
}
else { $x = @filesize($url); }
if (!$thereturn) { return $x ; }
elseif($thereturn == 'mb') { return round($x / (1024*1024),2) ; }
elseif($thereturn == 'kb') { return round($x / (1024),2) ; }
}
?>
The example :
<?php
echo urlfilesize('http://www.tayo.fr/remote-irc-tutoriel.php','mb')
?>