How to set directory permissions in php

藏色散人
Release: 2023-03-04 12:14:02
Original
4949 people have browsed it

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);
Copy after login

Function introduction:

chmod() function changes the file mode.

Returns TRUE if successful, otherwise returns FALSE.

Grammar

chmod(file,mode)
Copy after login

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!

Related labels:
php
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template