Return to Snippet

Revision: 138
at June 30, 2006 13:46 by cochambre


Initial Code
function getFileSize($bytes) {
   if ($bytes >= 1099511627776) {
       $return = round($bytes / 1024 / 1024 / 1024 / 1024, 2);
       $suffix = "TB";
   } elseif ($bytes >= 1073741824) {
       $return = round($bytes / 1024 / 1024 / 1024, 2);
       $suffix = "GB";
   } elseif ($bytes >= 1048576) {
       $return = round($bytes / 1024 / 1024, 2);
       $suffix = "MB";
   } elseif ($bytes >= 1024) {
       $return = round($bytes / 1024, 2);
       $suffix = "KB";
   } else {
       $return = $bytes;
       $suffix = "Bytes";
   }
   if ($return == 1) {
       $return .= " " . $suffix;
   } else {
       $return .= " " . $suffix . " ";
   }
   return $return;
}

Initial URL


Initial Description


Initial Title
Devuelve un string indicando del tamaño de un archivo al estilo Windows.

Initial Tags
file, style, windows

Initial Language
PHP