Home >Backend Development >PHP Problem >How to set directory permissions in php
In PHP, you can use the chmod function to set directory permissions. The chmod function is used to change the file mode. The setting method is "chmod('./xw/',0777);".
Recommended: "PHP Video Tutorial"
mkdir and chmod create directory folder permissions in php
Environment nging php linux
Use mkdir("路jin",777) to directly create the folder on the server. It is found that the permission attribute only displays "d" after generation. Naturally, Files cannot be uploaded in this directory. The code was later modified to: mkdir("path"); chmod("path",777); and the generated folder permission attribute is "drwxrwxrwx".
Summary:
php To create a directory with read and write permissions, it is best to use the following code. Do not directly use the mkdir function to specify permissions to avoid system umask Impact
mkdir('./xw/'); chmod('./xw/',0777);
Function introduction:
chmod() function changes the file mode.
Returns TRUE if successful, otherwise returns FALSE.
Grammar
chmod(file,mode)
The above is the detailed content of How to set directory permissions in php. For more information, please follow other related articles on the PHP Chinese website!