Tag Archives: filesize

Format file size

Code snippet to output number of bytes with unknown capacity: function format_filesize($bytes)  {     if ($bytes == 0)         return ’0.00 B’;     $s = array(‘B’, ’Kb’, ’MB’, ’GB’, ’TB’, ’PB’);     $e = floor(log($bytes)/log(1024));     return sprintf(‘%.2f ’.$s[$e], ($bytes/pow(1024, floor($e)))); } I don’t know the author of this code.

Posted in Uncategorized | Tagged , , , | 1 Comment