Page 2 of 2
Posted: Sat Oct 26, 2002 2:30 pm
by hob_goblin
Did you not read ANY of the post?
Did you not read ANY of the manual?
I mean, obviously, chmod() won't work. It's been stated over and over.
Posted: Sat Oct 26, 2002 2:32 pm
by Jay Eff
i have tried, but it doesn't work
Posted: Sat Oct 26, 2002 2:40 pm
by Takuma
How about this? Just a try
Where $file being a FILE name and not the directory...
And yes I have read the posts thanks...
You obviously using Linux so how about this?
Code: Select all
<?php
exec("CHMOD 777 /path/to/dir");
?>
It says on what I've found
There are two arguments for chmod: the permissions and the file/directory name. The permission argument for chmod is based on numbers.
1 stands for execute.
2 stands for write.
4 stands for read.
To set more than one permission on a file/directory, you just add up the permissions. For example, 7 means read, write, and execute permissions. Chmod takes the permissions as the first argument in the order user, group, global. Thus, the command chmod 777 hello will change the permissions of the file hello to read, write and execute by user, group, and everyone else.
Note: To change the permissions of a file/directory, you must be the owner of that file/directory. However, root can change permissions on any file/directory.
And I don't think 0 comes into it...
Posted: Sat Oct 26, 2002 3:11 pm
by hob_goblin
First of all, chmod only chmods files, and he's trying to chmod a directory.
We've tried the exec() thing, but obviously again, it's not working.
Its also been tried as 777 AND 0777, so that's not the problem.
Now, this is a stupid question but i forgot to ask, Jay Eff, you are running a Linux server right?
Posted: Sat Oct 26, 2002 3:36 pm
by Jay Eff
yes it is linux
Posted: Sun Oct 27, 2002 1:33 am
by Takuma
Posted: Sun Oct 27, 2002 3:34 am
by rev
I have not seen anyone mention the following, but it's critical to changing file permissions, opening files, writing files, or doing anything with a given file system in linux. The directory/file that you are attempting to open, which user/group has ownership of the directory and/or file? If the web server user does not have ownership then this might be keeping you from being able to manipulate the directory/file.
If it is a different user from the one running as web server (user nobody by default), and if you have command-line access and think it smart to do so, 'chown -R webServerUser.webServerGroup /path/to/dir' where, by default, webServerUser would be 'nobody' and webServerGroup would be 'nobody'.
Posted: Sun Oct 27, 2002 3:55 am
by volka
php-chmod-function works and it will change directory permissions as well, just like the shell-command does. Both use the same kernel-call.
when creating a directory from within a php-script note that
mkdir() can take a second parameter for the permission settings
also note
umask()
fileowner() will tell you the owner id. Your id should be stored in the enviroment variable UID or EUID (effectiv user id)
Code: Select all
echo 'uid:', getenv('UID'), ' euid :', getenv ('EUID');
or more likely to work
Code: Select all
system('echo $UID');
system('echo $EUID');
Posted: Sun Oct 27, 2002 10:24 am
by hob_goblin
Okay sorry for saying it 'can only' chmod files, but, from my experience alot of people have been having problems with directories. Most of these people got around it with using exec() somehow. The problem here is probably that php isn't finding the directory.