php - mkdir not obeying permission parameter -


i using mkdir in php script make file3 in directory /file/file2/file3. use permission 777 file looks dr----x--t 2 admin admin 4096 jul 1 19:26 file3 once made. running centos 5 64bit. file2 permission drwxrwxrwx 16 root root 4096 jul 1 19:26 file2 already. have ideas why is?

mkdir("/file1/file2/file3",777); 

you want use 777 octal, not decimal:

mkdir ("/file1/file2/file3", 0777); 

777 decimal turns out 1411 octal give bitmask 1 100 001 001 why you're getting "strange" permissions. standard set (last 3 segments) gives r----x--x , first segment modifies world permissions t (the sticky bit).

also keep in mind mkdir subject umask setting , may not give permissions ask (your umask setting gets "removed" permissions ask give actual permissions). see here details, including how avoid problem.

you're better off using mkdir create directory chmod (which isn't affected umask setting) change permissions.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -