note 86999 added to function.filesize
| From: | osmankhalid2005 at yahoo dot com | Date: | Fri, 14 Nov 2008 05:11:36 +0000 |
| Subject: | note 86999 added to function.filesize | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-146514@lists.php.net to get a copy of this message | ||
I developed a very easy to use and bug free function to convert bytes in other units. My MS in
Computer Engineering helped in devising this solution.
////////////////////////////////////////////
function GetFileSize($size)
{
$unit="";
if($size >=0 && $size < 1024)
{
$unit = " Bytes";
}
elseif($size >=1024 && $size < 1048576)
{
$size = round($size / 1024, 2);
$unit = " KB";
}
elseif($size >=1048576 && $size < 1073741824)
{
$size = round($size / 1048576, 2);
$unit = " MB";
}
elseif($size >=1073741824 && $size < 1099511627776)
{
$size = round($size / 1073741824, 2);
$unit = " GB";
}
return $size . $unit;
}
//===================================================================
----
Server IP: 69.147.83.197
Probable Submitter: 202.147.183.150
----
Manual Page -- http://www.php.net/manual/en/function.filesize.php
Edit -- https://master.php.net/note/edit/86999
Del: integrated -- https://master.php.net/note/delete/86999/integrated
Del: useless -- https://master.php.net/note/delete/86999/useless
Del: bad code -- https://master.php.net/note/delete/86999/bad+code
Del: spam -- https://master.php.net/note/delete/86999/spam
Del: non-english -- https://master.php.net/note/delete/86999/non-english
Del: in docs -- https://master.php.net/note/delete/86999/in+docs
Del: other reasons-- https://master.php.net/note/delete/86999
Reject -- https://master.php.net/note/reject/86999
Search -- https://master.php.net/manage/user-notes.php