How to check if file exists in PHP?

Member

by addison , in category: PHP General , 8 months ago

How to check if file exists in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 7 months ago

@addison use file_exists() function to check if file exists or not in PHP, code:


1
2
3
4
5
6
7
<?php

$path = '/path/to/file.txt';

if (file_exists($path)) {
    echo "file exists";
}