tags:

views:

117

answers:

6

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.

+2  A: 

You're missing quotes around the path name parameter.

Daniel Egeberg
The code actually has that in there... Sorry in my frustration I forgot add that in, I'll make an edit. Any other ideas?
Mike Keller
Make sure you've got error reporting turned on so you can see if it gives any warnings when calling the function.
Daniel Egeberg
+1  A: 

I had the same problem under Plesk, it turned out to be a bad server configuration that wouldn't allow me to make directories via code. Maybe check that out?

Raphael Caixeta
+1  A: 

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!

ajm
It's all good, I was afraid of that happening so I just made an edit to the original question.
Mike Keller
A: 

You must take the attribute in quotes:

mkdir('path/to/your/dir','0777');
Alexander.Plutov
no, the `$mode` parameter is defined as an octal int so you **should not** put quotes around it.
jordanstephens
I make a directory by this way. And all work.
Alexander.Plutov
+1  A: 

Are you trying to create those directories recursively, like you would do with mkdir -p on the command line? If so, specify true as the third parameter to mkdir.

And just to echo the previous suggestions, PLEASE specify the error messages you are getting. If you are not getting any, use this before your call: error_reporting(-1); // ALL messages and ini_set('display_errors', 'On');.

janmoesen
Thats pretty much the code I had at the beginning of the script.Except instead of the -1 I had this. Is it supposed to be the -1? I had ini_set('display_errors',1);error_reporting(E_ALL|E_STRICT)Am I supposed to be using -1 instead? 1 has always worked in the past in displaying errors.
Mike Keller
It is a bit mask, so -1 essentially is the same as "all bits set" for unsigned int. The effect will be the same. If, in some future version, they add another `E_XXX` constant which is not included in `E_ALL`, `-1` will include it anyway. Depends on what you prefer, basically.
janmoesen
+1  A: 

Have you tried with the shortest test possible?

mkdir('directory',0777);

If this does not work I would try creating with a standard CHMOD like 0755 (this is a totally random guess, maybe the server won't allow creating 0777 via PHP)

if this don't work I would say the server probably need different setup / php doesn' thave the writting right on folder, maybe you could ask your host provider?

Dominique