From docs, when calling filesize PHP caches this result in the stat ket.
Have you tried clearing the stat cache?
clearstatcache();
If this does not work, a workaround is perhaps to open the file, find its end, and then use ftell .
$fp = fopen($filename, "rb"); fseek($fp, 0, SEEK_END); $size = ftell($fp); fclose($fp);
If you are actually planning on displaying the output to the user, you can instead read the entire file and then strlen .
$data = file_get_contents($filename); $size = strlen($data);
source share