How to solve php is_writable failure problem

藏色散人
Release: 2023-03-12 15:10:01
Original
2666 people have browsed it

Solution to the failure of php is_writable: 1. Open the command window; 2. Execute "chcon -R -t httpd_sys_content_rw_t /var/www/html".

How to solve php is_writable failure problem

The operating environment of this article: centos7 system, PHP7 version, DELL G3 computer

How to solve the problem of php is_writable failure?

Specific problem description:

PHP7 is_writable always returns false!

My server is centos 7, and test.txt is just a test file I created on /var/www/html.

Permission is 766 1 root root test.txt

Modified nobody through chmod [Because php.net said that this function uses the identity of nobody for web access]

766 1 nobody root test.txt

<?php
$filename = &#39;test.txt&#39;;
if (is_writable($filename)) {
echo &#39;The file is writable&#39;;
} else {
echo &#39;The file is not writable&#39;;
}
?>
Copy after login

The final result is that it can be written when compiling on the server, but cannot be written when accessing the web. How to do it?

How to solve php is_writable failure problem

Solution:

chcon -R -t httpd_sys_content_rw_t /var/www/html
Copy after login

Recommended study: "PHP Video Tutorial"

The above is the detailed content of How to solve php is_writable failure problem. 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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!