Create a folder if it doesn't already exist

Solution for: How can we create a folder if it doesn't already exist?

Below the simple lines to Create a folder if it doesn't already exist.

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

Note that 0777 is already the default mode for directories and may still be modified by the current umask.

No comments:

Post a Comment