프로그래밍/PHP

파일 크기 구하는 함수

Crazy_Kong 2009. 5. 19. 16:15
function byteConvert($bytes) 

    $s = array('B', 'Kb', 'MB', 'GB', 'TB', 'PB'); 
    $e = floor(log($bytes)/log(1024)); 
      
    return sprintf('%.2f '.$s[$e], ($bytes/pow(1024, floor($e)))); 
}