Format file size in PHP
This function formats a file size. It takes in the number of bytes for the parameter and returns a string with the formated size.
function formatFileSize($theSize){ if($theSize < 1024){ return($theSize." Bytes"); }else if($theSize < 1024*1024){ return(number_format($theSize/1024,2,".","")." KB"); }else{ return(number_format($theSize/(1024*1024),2,".","")." MB"); } }
