PHP | filesize( ) Function Last Updated : 11 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The filesize() function in PHP is an inbuilt function which is used to return the size of a specified file. The filesize() function accepts the filename as a parameter and returns the size of a file in bytes on success and False on failure. The result of the filesize() function is cached and a function called clearstatcache() is used to clear the cache. Syntax: filesize($filename) Parameters: The filesize() function in PHP accepts only one parameter $filename. It specifies the filename of the file whose size you want to check. Return Value: It returns the size of a file in bytes on success and False on failure. Errors And Exception: For files which are larger than 2GB some filesystem functions may return unexpected results since PHP's integer type is signed and many platforms use 32bit integers. The buffer must be cleared if the filesize() function is used multiple times. The filesize() function emits an E_WARNING in case of a failure. Examples: Input : echo filesize("gfg.txt"); Output : 256 Input : $myfile = 'gfg.txt'; echo $myfile . ': ' . filesize($myfile) . ' bytes'; Output : gfg.txt : 256 bytes Below programs illustrate the filesize() function. Program 1: php <?php // displaying file size using // filesize() function echo filesize("gfg.txt"); ?> Output: 256 Program 2: php <?php // displaying file size using // filesize() function $myfile = 'gfg.txt'; echo $myfile . ': ' . filesize($myfile) . ' bytes'; ?> Output: gfg.txt : 256 bytes Reference: https://www.php.net/manual/en/function.filesize.php Create Quiz Comment S Shubrodeep Banerjee Follow 0 Improve S Shubrodeep Banerjee Follow 0 Improve Article Tags : Misc Web Technologies PHP PHP-file-handling Explore BasicsPHP Syntax4 min readPHP Variables5 min readPHP | Functions6 min readPHP Loops4 min readArrayPHP Arrays5 min readPHP Associative Arrays4 min readMultidimensional arrays in PHP5 min readSorting Arrays in PHP4 min readOOPs & InterfacesPHP Classes2 min readPHP | Constructors and Destructors5 min readPHP Access Modifiers4 min readMultiple Inheritance in PHP4 min readMySQL DatabasePHP | MySQL Database Introduction4 min readPHP Database connection2 min readPHP | MySQL ( Creating Database )3 min readPHP | MySQL ( Creating Table )3 min readPHP AdvancePHP Superglobals6 min readPHP | Regular Expressions12 min readPHP Form Handling4 min readPHP File Handling4 min readPHP | Uploading File3 min readPHP Cookies9 min readPHP | Sessions7 min read Like