View Full Version : Safe_mode Restriction

10-12-2004, 05:36 PM
I'm trying to use PHP to create a folder. I'm using the code
mkdir("../img/",0777);but every time I try and run the script I get the error message:

Now I've tried several things, like using chmod on the php file that's trying to run the prog.

Does anyone have any idea on what I can do?

Many thanks in advance,

10-12-2004, 09:43 PM
safe mode is an option set by your host to make php 'safer' in this case it appears to be blocking the chance to make new directories.

10-13-2004, 02:16 PM
I thought that this may be the case, but is there any way to 'disable' it temporarily by using ini_set or another method? I've been trying locally to change the value but can't seem to do it, even editing the php.ini file in notepad doesn't switch it on or off!

Many thanks for replying.

Many thanks in advance,

10-13-2004, 04:15 PM
2 things that could be at work here
1) you want to 'fix' your host ie edit the safe mode setting (can't do btw)
2) your running a local webserver with php installed and want to get that fixed.

If you are running the webserver and have access to php.ini as you stated look for:

; Safe Mode
safe_mode = Off

Around line 156

Understand though, your host (if your using one) will not allow you to edit the php.ini. You might contact them to find out if there is a different way to get the dirs made, who knows they might have a workaround for you.

10-14-2004, 10:08 AM
Thanks for your replies, I've emailed my host to ask if there's a workaround for it.

Many thanks again,

10-14-2004, 04:01 PM
Try using 0755 for the chmod param instead. PHP won't create 0777 directories, in my experience.

06-06-2006, 11:27 AM
well, safe_mode is one very nasty restriction...
on every object created(a dir, for instance), the user is set to someelse than owner of your script. (usually user = 'no-one' or something similar)

so, you can not access this dir.

option is that you choose cgi-script or ftp access.

06-06-2006, 11:32 AM
Thanks for the response. I decided to do both ftp and the standard php script i started with, but testing to see whether safe_mode is on or not before doing the appropriate method. Thanks for the reply though.

06-12-2006, 12:56 PM
that was my response to safe_mode too:)

06-12-2006, 02:41 PM
That's why I have a local webserver. Although I'm not sure what 0777 is.