I know there quite a bit of in-built functions available in PHP
to get size of the file, some of them are: filesize, stat, ftell, etc.
My question lies around ftell
which is quite interesting, it returns you the integer value of the file-pointer from the file.
Is it possible to get the size of the file using ftell
function? If yes, then tell me how?
Scenario:
ftell
to calculate the size of the file.fstat
determines the file size without any acrobatics:
$f = fopen('file', 'r+');
$stat = fstat($f);
$size = $stat['size'];
ftell
can not be used when the file has been opened with the append("a"
) flag. Also, you have to seek to the end of the file with fseek($f, 0, SEEK_END)
first.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With