Code (PHP): filesizeFormatted()
PHP function that returns file size of a given file as a string indicating size in kilobytes or megabytes, depending on whether the file is bigger than one megabyte.
function filesizeFormatted($filename) { $val=filesize($filename)/1024; if($val>1024) return "".number_format($val/1024,1,"."," ")." MB"; return "".number_format($val,1,"."," ")." kb";; }




