function humanFileSize($size) { if ($size >= 1073741824) { $fileSize = round($size / 1024 / 1024 / 1024,1) . \'GB\'; } elseif ($size >= 1048576)
I'm using this method:
function byteConvert($bytes) { if ($bytes == 0) return "0.00 B"; $s = array('B', 'KB', 'MB', 'GB', 'TB', 'PB'); $e = floor(log($bytes, 1024)); return round($bytes/pow(1024, $e), 2).$s[$e]; }
works great in o(1).