function renderSize($size){
$size = $size > (1024)
? ($size > (1024 * 1024)
? ($size > (1024 * 1024 * 1024)
? round($size / (1024 * 1024 * 1024),2 ) . "GB"
: round($size / (1024 * 1024),2) . "MB")
: round($size / 1024,2) . "KB")
: $size . 'Bytes';
return $size;
}
function file_size($path){
if(empty($path)){
return 0;
}
$path = ROOT_PATH . 'public/static/index/uploads/att/'.$path;
return renderSize(filesize($path));
}
![](https://i-blog.csdnimg.cn/blog_migrate/c23a6412863ed5b94865cf14be72aa41.png)