In PHP, mkdir() creates a new folder. You give it a path and, if you like, the permissions and an option to create missing parent folders.
It is the function you use to prepare upload folders, cache folders and log folders before saving files into them.
Syntax
Call mkdir() with the values you need. Start with this line.
PHP
$ok = mkdir('uploads', 0755);
Call
What it does
mkdir('uploads')
Creates a folder named uploads with the default permissions.
mkdir('uploads', 0755)
Creates the folder with permissions that let others read but not write.
mkdir('storage/logs/2026', 0755, true)
Creates the whole chain of folders in one call.
The permissions value should be written as an octal number with a leading zero, such as 0755. The final permissions are reduced by the current umask on Linux and macOS, and are mostly ignored on Windows. If the folder already exists, mkdir() returns false and shows a warning.