mkdir() not working

Mike Keller picture Mike Keller · Jun 24, 2010 · Viewed 40.8k times · Source

My code

mkdir("/some/absolute/path",0777);

and

mkdir("relative/path", 0777);

is not working, safe mode is turned off, and I've even tried setting all of the parent folders to 777.

Any ideas?

EDIT: I do have error reporting turned on, in my frustration I've 777'd the whole path just to make sure that, that isn't the issue. It's gotta be something stupidly simple going on.

EDIT EDIT: Upvotes for everyone who responded with suggestions... But I'm not going to select an answer since this still isn't resolved, but then again I think this is going to be one of those ones left open forever.

EDIT x 3: So I have the most unsatisfactory resolution to this question ever... I started with a clean VM image, retried it and it works now. No joke.

Answer

ajm picture ajm · Jun 24, 2010

Do all of the parent directories exist?

If not, you'll need to enable recursion (assuming PHP5 here):

mkdir('/path/to/your/dir',0777,true);

EDIT: Didn't see the hidden comment saying that every directory from var downward was set to world-writable, so I'm betting the directory path exists and the above won't be helpful. Sorry!