Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 10 of 10
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post

    Safe_mode Restriction

    I'm trying to use PHP to create a folder. I'm using the code
    PHP Code:
    mkdir("../img/",0777); 
    but every time I try and run the script I get the error message:
    SAFE_MODE RESTRICTIONS

    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,
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    Sheffield, UK
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    "To be successful in IT you don't need to know everything - just where to find it in under 30 seconds"

    (Me Me Me Me Me Me Me Me Me)

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    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,
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #4
    New Coder
    Join Date
    Nov 2002
    Posts
    87
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    Thanks for your replies, I've emailed my host to ask if there's a workaround for it.

    Many thanks again,
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #6
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try using 0755 for the chmod param instead. PHP won't create 0777 directories, in my experience.

  • #7
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.

  • #8
    Regular Coder
    Join Date
    Jun 2002
    Location
    Edinburgh, UK
    Posts
    402
    Thanks
    2
    Thanked 1 Time in 1 Post
    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.
    Rich

    "An expert is a person who has made all the mistakes that can be made in a very narrow field."

  • #9
    Regular Coder
    Join Date
    Aug 2004
    Posts
    280
    Thanks
    0
    Thanked 0 Times in 0 Posts
    that was my response to safe_mode too

  • #10
    Regular Coder
    Join Date
    Feb 2005
    Location
    Texas
    Posts
    472
    Thanks
    1
    Thanked 0 Times in 0 Posts
    That's why I have a local webserver. Although I'm not sure what 0777 is.
    If you're reading this, it may already be too late!


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •