There are 2 ways to the size of a file with PHP.
- PHP function filesize() returning the file size in bytes:
$bytes = filesize('log.txt'); // $bytes now contains the size of the file log.txt in bytes
- PHP function stat() returning an array of information about the file including the size of it, also in bytes:
$loginfo = stat('log.txt'); echo $loginfo['size']; // output the size of the file in bytes
1 thought on “PHP: Get File Size”
anyone know a way to say “if file size is smaller than” a certain value, then perform a function?
Comments are closed.