The
chmod function of php can change the access permissions of files and folders, but when used, a Warning message is displayed, as follows:
Warning: chmod() [function.chmod]: Operation not permitted in /export/myTest/chmodTest.php on line 5
The access permissions of all superior folders of the modified folder were changed to 777. The chmod function did not modify the access permissions of the folder at all. What is the reason? *nix just needs to make all the files in the web root directory owned by the apache running user. Assuming that there is an apache user in the apache group running httpd, then
chown -R apache.apache /path to DocumentRoot/
For win, the iis running user must have all permissions on DocumentRoot.
chmod() function changes the file mode. Return TRUE if successful, otherwise return FALSE.
Syntax
chmod(file,mode)
Description | |
---|---|
Required. Specifies the documents to be checked. | |
Optional. Specify new permissions. mode parameter consists of 4 numbers:
|
<?php // 所有者可读写,其他人没有任何权限 chmod("test.txt",0600); // 所有者可读写,其他人可读 chmod("test.txt",0644); // 所有者有所有权限,其他所有人可读和执行 chmod("test.txt",0755); // 所有者有所有权限,所有者所在的组可读 chmod("test.txt",0740); ?>
The above is the detailed content of Introduction to php chmod() function. For more information, please follow other related articles on the PHP Chinese website!