chmod problem

Discussion in 'PHP' started by cris02, Apr 26, 2007.

  1. #1
    hello, i would like to ask if there something wrong with this script, the problem is the chmod of the each folder it returns a 755 not a 777:
    
    $dirname = 'client/';
    mkdir($dirname.$_POST['username'],0777);
    mkdir($dirname.$_POST['username']."/uploads",0777);
    mkdir($dirname.$_POST['username']."/documents",0777);
    mkdir($dirname.$_POST['username']."/archive",0777);                             
    
    PHP:
    and another thing is when i manually create a folder i mean not using the script... then i change the chmod of each folder into 777. i can't upload the file it say Permission denied. what do you think is the problem? my server is linux, xpanel. is there a problem in configuration of the server?
    need help thanks...
     
    cris02, Apr 26, 2007 IP
  2. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #2
    Some servers are configured to allow a maximum value of 755 when php creates a directory and some limit all directories to a max of 755. The latter sounds like the situation in your case.

    755 allows you, the owner and the script to use the file in the normal manner. 777 grants those same rights to the world and can be a security issue.
     
    Colbyt, Apr 26, 2007 IP
  3. Adam A Flynn

    Adam A Flynn Peon

    Messages:
    19
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    One alternative may be to chown the client/ directory to apache or nobody (whichever user runs Apache) to allow file writing to the directory. It will mean, though, that you can't get at the files in those directories via FTP.
     
    Adam A Flynn, Apr 26, 2007 IP
  4. Colbyt

    Colbyt Notable Member

    Messages:
    3,224
    Likes Received:
    185
    Best Answers:
    0
    Trophy Points:
    210
    #4

    On servers running under PHPsuexec, Nobody is NOT an option. I quote from an email I received from one of my Hosts below.


    755 will be the maximum chmod on this server configuration.
     
    Colbyt, Apr 26, 2007 IP
  5. AleckProg

    AleckProg Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Alternative to resolve this is add CHMD 777 permission to FOLDER of files and it will be success.
     
    AleckProg, Apr 26, 2007 IP
  6. cris02

    cris02 Member

    Messages:
    55
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #6
    aww... thanks for the reply.. now i know. maybe it's on the server.. now my problem is i can't upload the file via FTP. thankss :)
     
    cris02, Apr 27, 2007 IP