assuming the variable with the path to the PHP file is called $file
$i = 0;
$ext = array (' B',' KB',' MB',' GB',' TB');
$filesize = filesize ($file);
while ($filesize >= pow (1024,$i)) ++$i; $filesize = round ($filesize / pow (1024,$i-1) * 100) / 100 . $ext[$i-1];
echo 'file: ' . $file . '<br>size: ' . $filesize;