homepage Welcome to WebmasterWorld Guest from 23.22.194.120
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Chmod script not working
chrissim




msg:4419028
 1:53 am on Feb 18, 2012 (gmt 0)

hi,

The following script below seem having problem with these error. i did tried to enter the full path to the file but seem not working.Please advise....


Warning: chmod() [function.chmod]: No such file or directory in /home/#*$!x/public_html/mysite.com/chmod.php on line 5




if(isset($_POST['dir'])){
$num = $_POST['num'];

chmod($dir, $num);
if(!$set){ echo "Error setting permissions"; } else { echo "Success!"; }

} else {
echo "<form action='$PHP_SELF' method='POST'>
Enter the directory to CHMOD
<input type='text' maxlength='48' length='24' name='dir'><br>
Enter permissions: <input type='text' maxlength='3' length='5' name='num'>
<input type='submit' name='chmod' id='chmod' value='chmod' />

</form>";


 

incrediBILL




msg:4419031
 2:21 am on Feb 18, 2012 (gmt 0)

What user is PHP running as?

In some installations it runs as Apache:Apache and others runs as the account Group:Owner , and can only set permissions on a directory if it's a directory where the permissions of PHP match those of the directory.

I have a situation on one server where I had to make a cron job running as root change the permissions on the directory for me because of such a mismatch problem. Normally it's something more easily fixed, but because I used a Plesk control panel for managing that server the cron job was the best solution I could find.

rocknbil




msg:4419591
 5:14 pm on Feb 20, 2012 (gmt 0)

Right, it's not always permissions, sometimes it's ownership. An example, if you upload a file via FTP under your account user, then try to chmod it with a script, you will get permission denied, and vice versa. These are different owners.

But your error trapping (good!) is telling you what the problem is. No such file or directory (NOT permission denied.) And you likely want to use the full path.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved