<?php
//获取文件大小并进行合适的格式转换
function getFileSize($filename){
	$size = filesize($filename);
	if($size >= pow(2,40)){
		$return = round($size / pow(1024,4),2);
		$suffix = 'TB';
	}elseif($size >= pow(2,30)){
		$return = round($size / pow(1024,3),2);
		$suffix = 'GB';
	}elseif($size >= pow(2,20)){
		$return = round($size / pow(1024,2),2);
		$suffix = 'MB';
	}elseif($size >= pow(2,10)){
		$return = round($size / pow(1024,1),2);
		$suffix = 'KB';
	}else{
		$return = $size;
		$suffix = 'Byte';
	}
   return $return.' '.$suffix;
}

?>