note 9359 added to filesize
| From: | eric at schorvitz dot com | Date: | Sun, 29 Oct 2000 01:16:08 +0000 |
| Subject: | note 9359 added to filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-7167@lists.php.net to get a copy of this message | ||
Here is a more compact way to accomplish converting file size to B, KB, MB, GB, TB as presented by
jesse@jess.on.ca below.
$j = 0;
$ext = array("B","KB","MB","GB","TB");
$file_size = filesize(<FILENAME>);
while ($file_size >= pow(1024,$j)) ++$j;
$file_size = round($file_size / pow(1024,$j-1) * 100) / 100 . $ext[$j-1];
http://www.php.net/manual/function.filesize.php