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 2 of 2
  1. #1
    Junsee
    Guest

    Folder Permissions

    I am having trouble implementing code for setting "Access All" on the folder permissions for my web folder.
    I've tried a number of lines of code but I can't seem to get it right. I am running a script install.php from a test folder

    like so:
    www.test.com/test/install.php

    I want to make /test/ 0777 permission, and it currently is set at 0755

    I've tried

    PHP Code:
    $FullPath $_SERVER['DOCUMENT_ROOT']. '/Test';
    echo 
    $FullPath;
    mkdir($FullPath,0777,true);
    chmod($FullPath0777) or die ("Permission not granted for root"); 
    also
    PHP Code:
    $FullPath '../Test'
    and just plain setting the chmod as 0777 (no mkdir)... its got me stumpped and banging my head!

    I have set perrimisions on this webserver before, so I can't understand why it refuses to work. In those cases I created folders first and then set the chmod, as I have a server that doesn't allow direct setting of mkdir permission, for whatever reason (which reminds me the webserver is linix based). The only thing I can think of is that some how you can't set permission of folder you are in?

    Going crazy ... and thanks in advance
    James

  • #2
    Senior Coder
    Join Date
    Sep 2010
    Posts
    1,912
    Thanks
    15
    Thanked 227 Times in 227 Posts
    Here's some code from one of my pages.
    PHP Code:
    if ((!file_exists($_SESSION["path"]))&&($_FILES['userfile']['name'] != "" ))
        {
        
    mkdir($_SESSION["path"]);
        
    chmod($_SESSION["path"],0777);
        if(!
    is_writable($_SESSION["my_path"]))
        die(
    'You cannot upload to the specified directory, please CHMOD it to 777.');
        } 
    You can't apply chmod to the whole path, only to the directory, without the end slash. 'my_path' in the above code is the whole path.


  •  

    Posting Permissions

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