Okay, when you run chmod() from within PHP, then the user that PHP is running under is the user that's trying to change the permissions level of the file.
If the PHP user doesn't have access to open or read the file to begin with, odds are it won't be able to grant itself access to do so. If that were the case, what good would having permissions be in the first place?
You need to log into the linux account that owns the directory and files you're trying to modify. Rich suggested using WS-FTP to do so, since it's a GUI based tool that allows you to perform simple shell commands like chmod.
If your webserver is your home computer, or if you have a telnet or ssh program on your home computer, then it's easy to just log into your linux web server using the account username and password that you use to write/upload your PHP files.
Go to the directory that your PHP scripts are located.
At the command line, type:
chmod 750 *.php
This sets your permissions to:
Code:
rwxrwx---
|||| +-> Group execute
|||+---> Group read
||+----> User execute
|+-----> User write
+------> User read
This means that any users in the user-group the file belongs to can read and execute your PHP scripts, but cannot modify or delete them. This also means that no other user on the system can read, write, or execute your PHP files.
Now, the only thing left to do is to change the group of your PHP files. Typically, this is "www" or "nobody" on linux systems.
chown <your_username>:nobody *.php
This keeps you as the file owner, and sets the group to be "nobody". That allows the webserver, via it's group access, to read and execute your php files.
The last thing you need to do is allow the webserver to create new files in your directory. You need to set additional permissions on the directory, similar to how we did for your PHP scripts. Type:
chmod 770 .
This sets full (Read/Write/eXecute) permissions for both you, the user, and the group. We still need to make sure that the webserver has this access via the group. Type:
chown <your_username>:nobody .
That sets the directory's group to be "nobody".
Now, PHP (via the web-server's group), can read and execute existing files in your directory and create new ones.
If you're still having problems, let us know.
Take care,
Nik
http://www.bigaction.org/