My code
mkdir(\"/some/absolute/path\",0777);
and
mkdir(\"relative/path\", 0777);
is not working, safe mode is
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');
.
If anyone gets stuck with this problem.. there's one answer I can give you that I spend 2 hours on finding.. I tried with using a full path, and "../mydirectoryname".
Try using:
mkdir("./mydirectoryname", 0777, true);
Instead of..
mkdir("../mydirectoryname", 0777, true);
For future references, the problem might come from the possibility that the directory where you're trying to create your new directory doesn't have enough permission.
For instance, your index directory might look like this:
index.php new_dirs_here
if new_dirs_here
doesn't have enough permission then you can't create direcories inside.
To solve this, I'd use the command:
chmod 777 new_dirs_here
I'm not worrying about security now, Just trying to solve the immediate problem. You could of course look up a better permission settings, but the idea is that your new_dirs_here
should have enough permissions.
Then, your mkdir()
dunction should work just fine.
Good luck
You must take the attribute in quotes:
mkdir('path/to/your/dir','0777');
I have similar problem and I found out, that I have no free space left on my drive. Check with command df
(on linux) how full is your drive. It is possible that root is allowed to create files and folders in this situation, because he has pre-reserved space. If you run you script from command-line as root
user - there is no error, but if your script is run by apache
, then error occure.
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!