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

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published.