Tuesday, October 11, 2011

Changing FilePermission and Ownership using PHP's chmod() function

Changing FilePermission and Ownership using PHP's chmod() function:

Chmod() is used for changing permissions on a file.

Syntax:
Chmod(file, mode)

Mode here specifies the permissions as follows:

* The first number is always zero
* The second number specifies permissions for the owner
* The third number specifies permissions for the owner's user group
* The fourth number specifies permissions for everybody else


Possible values (to set multiple permissions, add up the following numbers)

* 1 = execute permissions
* 2 = write permissions
* 4 = read permissions


Example:

// everything for owner, read for owner's group
chmod("test.txt",0740);


No comments:

Post a Comment