function getsizebytes($sz) { if($sz < 1024) return ($sz . " bytes"); if($sz < 1048576) return (number_format($sz/1024, 2)." Kb"); if($sz < 1073741824) return (number_format($sz/1048576, 2)." Mb"); return (number_format($sz/1073741824, 2)." Gb"); }
Ya pronto habrá que agregarle los Terabytes (1099511627776 bytes), los Petabytes (1125899906842624 bytes) y los Exabytes (1152921504606846976 bytes)... ;)