Home  >  Article  >  Backend Development  >  What should I do if php cannot write files?

What should I do if php cannot write files?

藏色散人
藏色散人Original
2020-07-30 10:26:391962browse

php cannot write files because the permissions are insufficient. The solution is to change the permissions of the specified file through the "chmod()" function in php. The syntax of this function is "chmod(file,mode)", and the parameters "mode" indicates new permissions.

What should I do if php cannot write files?

Recommended: "PHP Video Tutorial"

chmod() Function changes the specified file permission.

Returns TRUE if successful and FALSE if failed.

Syntax

chmod(file,mode)

Parameters

file required. Specifies the documents to be checked.

mode Required. Specify new permissions.

The mode parameter consists of 4 numbers:

The first number is usually 0

The second number specifies the owner's permissions

The third The first number specifies the permissions of the user group to which the owner belongs

The fourth number specifies the permissions of everyone else

Possible values ​​(if you need to set multiple permissions, please adjust the numbers below Total):

1 = Execute permission

2 = Write permission

4 = Read permission

Instance

<?php
// Read and write for owner, nothing for everybody else
chmod("test.txt",0600);
// Read and write for owner, read for everybody else
chmod("test.txt",0644);
// Everything for owner, read and execute for everybody else
chmod("test.txt",0755);
// Everything for owner, read for owner&#39;s group
chmod("test.txt",0740);
?>

The above is the detailed content of What should I do if php cannot write files?. 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