Home  >  Article  >  Backend Development  >  How to set directory permissions in php

How to set directory permissions in php

藏色散人
藏色散人Original
2020-08-13 10:33:174935browse

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);".

How to set directory permissions in php

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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn