I'm trying to unlink (delete) a bunch of files but first I need permission to do so. When I manually set the permissions it works. However, when I try doing it in my php file I get the following error:

Warning: chmod failed: Operation not permitted in /home/virtual/site38/fst/var/www/html/backoffice/admin.php on line 18

That line of code is simply:
chmod("/home/virtual/site38/fst/var/www/html/backoffice", 777);

Any ideas?

    chmod values need to be in octal form. try this:

    <?php
    chmod("/home/virtual/site38/fst/var/www/html/backoffice", 0777);
    ?>

      wait. doesn't PHP run as nouser or nobody? remember that only the owner or root can chmod something

        The weird thing about it is it lets me chmod the files/directories IF I create them in the php file. However, if they were created outside the program, like me manually FTPing in and creating them, I can't chmod them from inside the file. Safe Mode has been disabled on the server so I can't figure out why it wont let me do it. Anyone know any ways around this? Basically all I really want to accomplish is deleting a directory that has files in it. I wrote a function to do this but I need permission to unlink/rmdir the files first.

          Write a Reply...