Here we are solving a basic problem faced by a beginner web developer in PHP i.e. How to change file mode in PHP
// Read and write for owner, nothing for everybody else
// Read and write for owner, read for everybody else
// Everything for owner, read and execute for others
// Everything for owner, read and execute for owners group
attempts to change the mode of the file to that given in mode.
bool chmod ( string $filename , int $mode )
Path to the file.
Note that mode is not automatically assumed to be an octal value, so to ensure the expected operation,
you need to prefix mode with a zero (0). Strings such as "g+w" will not work properly.
The mode parameter consists of three octal number components specifying access restrictions for the owner, the user group in which the owner is in, and to everybody else in this order. One component can be computed by adding up the needed permissions for that target user base. Number 1 means that you grant execute rights, number 2 means that you make the file writeable, number 4 means that you make the file readable.
Add up these numbers to specify needed rights. You can also read more about modes on Unix systems with 'man 1 chmod'
and 'man 2 chmod'
This function will not work on remote files as the file to be examined must be accessible via the server's filesystem.