How to set permissions for a new folder in php

藏色散人
Release: 2023-03-08 11:10:02
Original
2805 people have browsed it

How to create a new folder in php and set permissions: first create the directory through "mkdir('./xw/');"; then use "chmod('./xw/',0777);" Just specify the permissions.

How to set permissions for a new folder in php

The operating environment of this article: linux5.9.8 system, PHP version 7.1, Dell G3 computer.

Mkdir and chmod in php create directory folder permissions

Environment nging php linux

Use mkdir("Road Jin",777 on the server ) directly created the folder, and found that the permission attribute only showed "d" after generation. Naturally, files could not be uploaded in this directory. Later, the code was modified to: mkdir("Lu Jin"); chmod("Lu Jin",777); The generated folder permission attribute is "drwxrwxrwx".

Summary:

If php wants 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 the impact of the system umask

mkdir('./xw/'); 
chmod( './xw/',0777);
Copy after login

[Recommended learning: "PHP Video Tutorial"]

The above is the detailed content of How to set permissions for a new folder 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