日期:2014-05-17 浏览次数:20702 次
<?php function getFileSize($file_name){ $K = 1024; $M = 1024*$K; $G = 1024*$M; $file_size = filesize($file_name); if($file_size>$G){ $file_size = ($file_size / $G)." G"; }elseif($file_size>$M){ $file_size = ($file_size / $M) ." M"; }elseif($file_size > $K){ $file_size = ($file_size /$K). " K"; }else{ $file_size = $file_size. " byte"; } return $file_size; } echo getFileSize("new_file.html"); ?>