Home > Article > Backend Development > php filesize function_PHP tutorial
php filesize function
filesize
(PHP 4, PHP 5)
filesize - Get file size
Description
international filesize(String$filename)
Get a file of a given size.
Parameters
File name
File path.
Return value
Returns the size of the file in bytes, or FALSE (and generates error level E_WARNING) in case of an error.
NOTE: Due to PHP's signature of integer types and the use of 32-bit integers by many platforms, filesize() may return unexpected results for files larger than 2GB in size. For file sizes of 2GB and 4GB this can usually be overcome using sprintf("%u", filesize($file)).
Example
Example of #1filesize()
// outputs e.g. somefile.txt: 1024 bytes
$filename = 'somefile.txt';
echo $filename . ': ' . filesize($filename) . ' bytes';
?>