Ben
Ben

Reputation: 62384

mkdir() not chmodding the directory

I'm using the following code to create a directory...

mkdir($basedir.$plan_name, 0777, 1);

It creates, but the issue is that the 777 permissions aren't sticking

Any ideas?

My directory structure is this....

/pdf/customs (owned by wwwuser:user) /pdf/customs/417/Folder Name (created by code, modded to 755)

Upvotes: 1

Views: 229

Answers (3)

Dietrich Epp
Dietrich Epp

Reputation: 213338

Your umask is probably 022. For more information, read man 2 mkdir. You must use chmod after you make the directory to set the permissions to 0777.

Edit: As others have suggested, you can change your umask instead. However, if something goes wrong, the umask will stick around and your webserver or fastcgi daemon (or whatever) will start creating world-writable files and directories. That's bad news.

Upvotes: 4

Anders Lindahl
Anders Lindahl

Reputation: 42870

From the documentation:

Note that you probably want to specify the mode as an octal number, which means it should have a leading zero. The mode is also modified by the current umask, which you can change using umask().

What is your umask?

Upvotes: 0

Alnitak
Alnitak

Reputation: 339816

Did you check your umask ?

The directory permissions will be modified by that. For example if your umask value is 002 the resulting permissions will be 0775.

Upvotes: 0

Related Questions