How to check if file exists in PHP?

Member

addison

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

How to check if file exists in PHP?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by darion , 3 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";
}