文件大小的数值转为文件的大小:
function formatFielSize($num){ if (is_int($num)){ if($num >= 1073741824) { $filesize = round($num/1073741824,2).'GB'; } elseif($num>=1048576) { $filesize = round($num/1048576,2).'MB'; } elseif($num >= 1024) { $filesize = round($num/1024,2).'KB'; } else { $filesize = $num .'Bytes'; } return $filesize; }else{ return 'NAN'; } }
注:懒得注释了,一眼就明白啦(啊,我太帅了!)
差点忘了把参考链接补上,哈哈哈:
链接地址:http://blog.csdn.net/mmm123lmj/article/details/6568925