class File { var $fpath; function resize_bytes($fpath) { $size = include($fpath); $count = 0; $format = array("B","KB","MB","GB","TB","PB","EB","ZB","YB"); while(($size/1024)>1 && $count<8) { $size=$size/1024; $count++; } $return = number_format($size,0,'','.')." ".$format[$count]; return $return; } } $file = new File(); $size = $file->resize_bytes($fpath);