public function getHumanReadableSize($size, $unit = null, $decemals = 2)
{
$byteUnits = array(' B', ' KB', ' MB', ' GB', ' TB', ' PB', ' EB', ' ZB', ' YB');
if (!is_null($unit) && !in_array($unit, $byteUnits)) {
$unit = null;
}
$extent = 1;
foreach ($byteUnits as $rank) {
if (is_null($unit) && $size < ($extent <<= 10) || $rank == $unit) {
break;
}
}
return number_format($size / ($extent >> 10), $decemals) . $rank;
}