PHP Devuelve un string indicandodeltamaño de un archivo al estilo Windows。

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Devuelve un string indicandodeltamaño de un archivo al estilo Windows。相关的知识,希望对你有一定的参考价值。

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;
}

以上是关于PHP Devuelve un string indicandodeltamaño de un archivo al estilo Windows。的主要内容,如果未能解决你的问题,请参考以下文章