Skip to content
PHP Logo

How can the filesize() function be used to determine the size of a file in PHP?

To determine the size of a file in PHP, you can use the filesize() function. This function takes a file path as a parameter and returns the size of the file in bytes. You can use this information to display the file size to the user or perform other operations based on the file size.

php
$file = 'path/to/your/file.txt';
$fileSize = filesize($file);

echo "The size of the file is: " . $fileSize . " bytes";