Results 1 to 6 of 6
  1. #1
    Join Date
    May 2002
    Location
    Durham - UK
    Posts
    450

    Question CHMOD through PHP

    Hi
    I have designed a few PHP scripts in the past but I would like to create a sort of installer file that will setup all the file permissions needed to run a program.

    Does anyone know if it is actually possible to chmod a file or folder through a PHP file and if so how?

    Any help would be really good.
    Barry
    UK Based Freelance PHP Developer
    PHP/SQL/Ajax/HTML5 - Contact for Quote

  2. #2
    Join Date
    Dec 2001
    Location
    New Hampshire
    Posts
    93

  3. #3
    Join Date
    May 2002
    Location
    Durham - UK
    Posts
    450
    Hi
    I tried the script in the manual, but it didn't seem to work as the file's permission didnt seem to change.
    Barry
    UK Based Freelance PHP Developer
    PHP/SQL/Ajax/HTML5 - Contact for Quote

  4. #4
    Join Date
    May 2002
    Location
    UK
    Posts
    2,997
    chmod is also a protected function under safe_mode although you are not restricted from executing it.

  5. #5
    Join Date
    May 2002
    Location
    Durham - UK
    Posts
    450
    Upon viewing the following code via web browser i get the errors posted below:

    <?
    chmod ("/home/dedi/public_html/demo/sessions", 0777);
    chmod ("/home/dedi/public_html/demo/admin/admin_1.php", 0666);
    ?>


    Shows:

    Warning: chmod failed: Operation not permitted in /home/dedi/public_html/demo/install.php on line 2

    Warning: chmod failed: Operation not permitted in /home/dedi/public_html/demo/install.php on line 3
    Barry
    UK Based Freelance PHP Developer
    PHP/SQL/Ajax/HTML5 - Contact for Quote

  6. #6
    Join Date
    Mar 2002
    Location
    San Jose, CA
    Posts
    34
    the web server most likely runs as "nobody" or some other less-priveleged user. So the files/directories you are trying to chmod must be owned by the user "nobody" which will most likely never be the case unless you set them explicitly, which would defeat the whole purpose of doing it in your script anyway!
    ranchoweb.com
    reliable linux hosting with all the trimmings
    http://www.ranchoweb.com/webhost/

Posting Permissions

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