How to check if File Exists in PHP ? Last Updated : 23 Jul, 2025 Comments Improve Suggest changes Like Article Like Report To check whether any file is existing or not then we can use the below-mentioned PHP function. To find the existence of the files, we use file_exists() function. This function is used to check whether a file or directory exists or not. Syntax: file_exists( $path ) Parameters: This function accept only one parameter $path. It specifies the path of the file or directory you want to check. Return Value: It returns True on success and false on failure. Errors And Exception: The file_exists() function returns False if the path specified points to non-existent files. For files larger than 2gb, some of the filesystem functions may give unexpected results since PHP’s integer type is signed and many platforms use 32bit integers. Example: Suppose there exists a file named "file1.php". Let's check the existence of files "file1.php". PHP <?php $filename = "file1.php"; if (file_exists($filename)) { echo "File exist."; } else { echo "File does not exist."; } ?> Output File exist. Comment A akshitsaxenaa09 Follow 0 Improve A akshitsaxenaa09 Follow 0 Improve Article Tags : Web Technologies PHP PHP-file-handling PHP-function PHP-Questions +1 More Explore PHP Tutorial 8 min read BasicsPHP Syntax 4 min read PHP Variables 5 min read PHP | Functions 8 min read PHP Loops 4 min read ArrayPHP Arrays 5 min read PHP Associative Arrays 4 min read Multidimensional arrays in PHP 5 min read Sorting Arrays in PHP 4 min read OOPs & InterfacesPHP Classes 2 min read PHP | Constructors and Destructors 5 min read PHP Access Modifiers 4 min read Multiple Inheritance in PHP 4 min read MySQL DatabasePHP | MySQL Database Introduction 4 min read PHP Database connection 2 min read PHP | MySQL ( Creating Database ) 3 min read PHP | MySQL ( Creating Table ) 3 min read PHP AdvancePHP Superglobals 6 min read PHP | Regular Expressions 12 min read PHP Form Handling 4 min read PHP File Handling 4 min read PHP | Uploading File 3 min read PHP Cookies 9 min read PHP | Sessions 7 min read Like