PHP - How to check if a file or directory already exists
<?php
// directory path or file name
// For eg: 2019/11
// or 2019/11/photo.png
$directoryPath = "2019/11";
if(!file_exists($directoryPath)){
exit("{$directoryPath} doesn't exist");
}
exit("{$directoryPath} exists");
// you could use ternary operator
file_exists() can be used to check if a file or folder exists