function humanFileSize($size)
{
if ($size >= 1073741824) {
$fileSize = round($size / 1024 / 1024 / 1024,1) . \'GB\';
} elseif ($size >= 1048576)
Try something like this:
function humanFileSize($size,$unit="") {
if( (!$unit && $size >= 1<<30) || $unit == "GB")
return number_format($size/(1<<30),2)."GB";
if( (!$unit && $size >= 1<<20) || $unit == "MB")
return number_format($size/(1<<20),2)."MB";
if( (!$unit && $size >= 1<<10) || $unit == "KB")
return number_format($size/(1<<10),2)."KB";
return number_format($size)." bytes";
}