Warning: Chmod() [function.chmod]: Operation Not Permitted

windows

Guest
hi i get that error when i do a test chmod on a folder. how to i make it work?<br /><br />here is the phpinfo:<br /><br /><a href="http://eubankers.net/phpinfo.php" target="_blank">http://eubankers.net/phpinfo.php</a><br /><br /><br />ty!<!--content-->
Do you have the correct permissions set on the folder containing the folder you are trying to chmod?<!--content-->
hi!<br /><br />i set the folder where the script is running to 777 but i still get that warning<!--content-->
And is the folder you are trying to chmod contained within the folder you have set to 777 ?<!--content-->
yes it is.. basically, i did a test by doing:<br /><br /><br />/public_html/testfolder/<br /><br />I chmod public_html to 777<br /><br />and the test script is inside it<br /><br />with this:<br /><br /><?<br />chown("testfolder/", nobody); <br />chmod("testfolder/",777);<br />?><br /><br /><br />you can see here<br /><br /><a href="http://eubankers.net/test.php" target="_blank">http://eubankers.net/test.php</a><!--content-->
Yes but PHP can not chmod testfolder unless public_html is chmodded to 777. <br /><br />try<br /><br /><!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1--><?<br />if (@chown("testfolder/", nobody))<br />   echo 'Owner changed<br>';<br />else<br />   echo 'Failed to change owner<br>';<br />if (@chmod("testfolder/",777))<br />   echo 'Folder permissions changed';<br />else<br />   echo 'Failed to change permissions';<br />?><!--c2--></div><!--ec2--><!--content-->
done.<br /><br />i did chmod 777 the public_html folder<br />lrwxrwxrwx 1 0 0 11 May 12 02:53 www -> public_html<br /><br />same problem:<br /><br />Failed to change owner<br />Failed to change permissions<br /><br /><br /><br />ty<!--content-->
Tried using full paths?<!--content-->
it ried full path, same problem:<br /><br /><?<br /> <br /><br />if (@chown("/home/eubfnco/public_html/testfolder/", nobody))<br /> echo 'Owner changed<br>';<br />else<br /> echo 'Failed to change owner<br>';<br />if (@chmod("/home/eubfnco/public_html/testfolder/",777))<br /> echo 'Folder permissions changed';<br />else<br /> echo 'Failed to change permissions';<br />?><!--content-->
Try it on a folder within testfolder.<br /><br />Failing that have a look at php.net/chmod where someone has posted the code to do it by FTP.<!--content-->
thanks carbonize, <br /><br />but same problem. i also set the folder to 777 .<br /><br />i'll just open a ticket about this.<br /><br />ty<br /><!--content-->
hi got a reply from support:<br /><br /><br />The files/folders you are trying to perform chmod/chown should be under the ownership of Apache (nobody).<br /><br /><br /><br /><br />thanks to tina.<br /><br />hmm so my problem now is that i'll need to first chown the folder to nobody from ssh before i can chmod it.<br /><br />or..<br /><br />i'll need to have php create the folder first so that it owns it and then i can chmod it.<br /><br />ty<br /><br /><br /><br /><br /><br /><!--content-->
You can't "chown" as a regular user. If you want existing files to have ownership of nobody, you will have to submit a helpdesk ticket.<br /><br />Also, just a word of caution, having public_html with 777 permissions is not a wise idea for security reasons. Any compromise on your site at all, and they can change anything within your website. If you only need to have your script be able to write to "testfolder" you can set testfolder to 777 and leave public_html as 755.<!--content-->
 
Top