public static function format($bytes, $decimals = 2)
{
$exp = 0;
$value = 0;
$symbol = array('B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
$bytes = floatval($bytes);
if ($bytes > 0) {
$exp = floor(log($bytes) / log(1024));
$value = $bytes / pow(1024, floor($exp));
}
if ($symbol[$exp] === 'B') {
$decimals = 0;
}
return number_format($value, $decimals, '.', '') . ' ' . $symbol[$exp];
}