Create a folder if it doesn’t already exist PHP

To create a folder if it doesn’t already exist in PHP use below code

<?php
if (!file_exists('path/to/directory')) {
    mkdir('path/to/directory', 0777, true);
}
?>

Leave a Comment

Your email address will not be published.