A
A
AlexRas2020-03-19 12:58:33
PHP
AlexRas, 2020-03-19 12:58:33

The mkdir function does not create a folder with permissions of 775 and 777, but creates 755 in both cases. What's the matter?

Hello everyone, here is the code:

mkdir($_SERVER['DOCUMENT_ROOT'] . '/test/', 0777, true);

When executed, it creates a folder with a permission of 755, but it needs a permission of 777. Also, if you specify a resolution less than 700 in the function, then the permissions are set correctly. Please tell me how to solve it.

PHP 7.4
Ubuntu 18

Answer the question

In order to leave comments, you need to log in

4 answer(s)
N
nokimaro, 2020-03-19
@AlexRas

$old_umask = umask(0);
mkdir($_SERVER['DOCUMENT_ROOT'] . '/test/', 0777, true);
umask($old_umask);

S
Sergey, 2020-03-19
@KingstonKMS

Why do you need such permissions? Read about it before setting such permissions.

V
Viktor Taran, 2020-03-19
@shambler81

you do not need to create 777, this indicates that you have an error with the rights. but this is not a reason to decide it in such an occasion.

V
Vladimir Korotenko, 2020-03-19
@firedragon

man umask
I suspect that this is the case

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question