How to create new folder using php

In this tutorial we will create new folder using php. i have used the mkdir command to make a folder, however i would like it to make a folder based on the username of the person who is currently logged in. You may also like How to check a folder doesn’t already exist using php and How to Copy file from one folder to another 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 );
}

Leave a Reply

Your email address will not be published. Required fields are marked *