How to check a folder doesn’t already exist using PHP
In this tutorial we will create a new folder using mkdir command and check if condition folder exist and not exist using is_dir command below code available so check..
PHP Code
$candidate_id = 1;
if (! is_dir ( './public/images/candidate/'.$candidate_id )) {
mkdir ( './public/images/candidate/'.$candidate_id, 0777, true );
}
if (! is_dir ( './public/images/candidate/'.$candidate_id.'/candidate_photo' )) {
mkdir ( './public/images/candidate/'.$candidate_id.'/candidate_photo', 0777, true );
}
Leave a Reply