A function to return a formatted filesize (b, kb, mb, gb)
<? function mk_nice_filesize($fpath) { $d = filesize($fpath); $text = "B"; if ($d > 1023) { $d = round(($d/1024),2); $text = "KB"; if ($d > 1023) { $d = round(($d/1024),2); $text = "MB"; if ($d > 1023) { $d = round(($d/1024),2); $text = "GB"; } } } return $d . " " . $text; } ?>
Just pass the full path of the file to this function to get a formatted filesize.
Comments
Add your comment