{"id":12190,"date":"2022-05-11T04:25:43","date_gmt":"2022-05-11T08:25:43","guid":{"rendered":"http:\/\/local.brightwhiz\/?post_type=snippets&p=12190"},"modified":"2022-05-11T04:25:46","modified_gmt":"2022-05-11T08:25:46","slug":"php-check-if-file-exists","status":"publish","type":"snippets","link":"http:\/\/local.brightwhiz\/snippets\/php-check-if-file-exists\/","title":{"rendered":"Check if File Exists Using PHP"},"content":{"rendered":"\n
Use this code snippet to check if file exists using PHP.<\/p>\n\n\n\n
$filename\u00a0=\u00a0'\/path\/to\/file.txt';\n\nif\u00a0( file_exists( $filename ) )\u00a0{\n\n \/\/ do something with the file\n\n}\u00a0else\u00a0{\n\n\u00a0\u00a0\u00a0\/\/ file does not exist\n\n}<\/code><\/pre>\n","protected":false},"comment_status":"open","ping_status":"closed","template":"","meta":[],"categories":[953,25,27,15,16],"tags":[350,424,433,449,452,544,638],"yoast_head":"\nPHP Check if File Exists Example<\/title>\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\n