Home » Create a folder if it doesn’t already exist PHP

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