Bladephp: Now with 8+ codeigniter, php, and laravel project 8+ php project From $37/Month From Rs. 2499/Month

How to check a folder doesn't already exist using php

by
Category:php
php
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. You may also like How to Copy file from one folder to another folder using PHP and How to create new folder using php.

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 );
}

0 Comments


Html code work in comment box


Related Post