PHP mkdir() permissions

samach picture samach · Oct 24, 2011 · Viewed 14.8k times · Source

I have a Linux server with appache as the web server. In my PHP script I am making directories with 0777 mode. the code is pretty simple as follows:

mkdir($path,0777)

when I run this script and go to my server file manager, the folder is there but the permission assigned to that folder is 0755. I can't figure out why this is happening!! when the folder is created the user column has apache in it but the permission is 0755.

Answer

Shakti Singh picture Shakti Singh · Oct 24, 2011

You should try with the umask

$old = umask(0); 
mkdir($path,0777); 
umask($old);