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
You should also read:
- Use stat command to display file system meta information of any file or directory under Linux
- Check for file size with JavaScript before uploading
- PHP: Get the File Uploading Limit – Max File Size Allowed to Upload
- PHP: Get Mime Type of a File (and Encoding)
- PHP: Find and Return the Minimum (Lowest) Value or Maximum (Highest) Value of Several Numbers


Facebook
Twitter
Google Plus
{ 1 comment… read it below or add one }
anyone know a way to say “if file size is smaller than” a certain value, then perform a function?