Web Hosting Talk







View Full Version : CHMOD through PHP


barrywien
09-13-2002, 06:35 AM
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.:)

prosayist
09-13-2002, 06:45 AM
http://www.php.net/chmod

barrywien
09-13-2002, 06:47 AM
Hi
I tried the script in the manual, but it didn't seem to work as the file's permission didnt seem to change.

Rich2k
09-13-2002, 06:51 AM
chmod is also a protected function under safe_mode although you are not restricted from executing it.

barrywien
09-13-2002, 06:55 AM
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

ranchoweb
09-13-2002, 12:50 PM
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!