Check if File or Directory Exists using PHP

file_exists function

<?php

$pathname = 'dir/test.txt';
$result = file_exists($pathname);

echo $result ? 'Yes' : 'No';

Leave a Comment

Cancel reply

Your email address will not be published.