Chmod not working

I am trying to CHMOD a directory in my html folder (/var/www/html) but it consistently fails to change it.

Are there some kind of permissions I need to change somewhere to allow this.
chmod("/var/www/html/thunder", 0777);

Open in new window

albyhAsked:
Who is Participating?
 
OnthraxConnect With a Mentor Commented:
In that case.. please check the first note on this page:

http://nl.php.net/chmod

Note: The current user is the user under which PHP runs. It is probably not the same user you use for normal shell or FTP access. The mode can be changed only by user who owns the file on most systems. 

Open in new window

0
 
reza81Commented:
try 777, not 0777
0
 
albyhAuthor Commented:
Im afraid that doesnt work and is the incorrect way of listing the function according to php.net

"To ensure the expected operation, you need to prefix mode  with a zero (0): "
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
reza81Commented:
Ok, can you make the directory you want to chmod with php and than try to change it if needed.

I think that would do the trick
0
 
reza81Commented:
$tid = "namedir";

if (chmod(mkdir("thunder/" . $tid), 0777)) echo "Dir creation and chmod ok!";

or something like this... my php isn't that good :-)
0
 
albyhAuthor Commented:
I cant create a directory with PHP in the public_html root folder as the permissions wont let me
0
 
OnthraxCommented:
Open up your FTP program, login to your account and use that to change the permissions. FTP usually has a little more rights than directly from PHP files.
0
 
albyhAuthor Commented:
Hi Onthrax,

That method works but unfortunately is no good for me in this situation as the chmod is part of a PHP script.
Basically the script creates a directory and then "should" change the permissions of it so that pictures can be uploaded into it.
0
 
albyhAuthor Commented:
Question not fully solved
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.