4

Possible Duplicate:
PHP mkdir 0777 fail chmod 0777 works

My PHP code has something like this:

$success = mkdir($directory_name, 0777, TRUE);

When I look at the actual folder it created, the permissions are 0755. Any ideas what might be causing this?

Community
  • 1
  • 1
StackOverflowNewbie
  • 39,403
  • 111
  • 277
  • 441

2 Answers2

5

The actual permissions are impacted by the current umask() value. If it is limited to 755, so will the directory permissions. (It's xored off the requested 777)

mario
  • 144,265
  • 20
  • 237
  • 291
2

Your umask is probably set to 0022 (a common default), preventing the write bits from being set for group and other. You can use the umask function to change the current umask.

But then, why are you creating a directory that's world-writable? Not a good idea.

Nicholas Knight
  • 15,774
  • 5
  • 45
  • 57