Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

Chmod script not working

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

Junior Member

5+ Year Member

joined:July 24, 2009
posts: 113
votes: 0


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

$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' />


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

System Operator from US 

incredibill is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month

joined:Jan 25, 2005
votes: 99

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.
5:14 pm on Feb 20, 2012 (gmt 0)

Senior Member

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member

joined:Nov 28, 2004
votes: 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.

Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members