Create a folder using PHP code

Á

Álvaro Moura

Last updated on Jul 6, 2026

To create a folder on the server partition, use the PHP command: mkdir ();

In the example below, I will create a folder where your name will be the current system date.

$folder = date("Ymd");mkdir ($folder, 0755); ?>

The value "0755", will be allowed to read / write the new folder.

I remember:

For dedicated servers, you can use 777.

To host servers / cpanel, you should use the permission to 755.

Source:

http://br.php.net/manual/pt_BR/function.mkdir.php