Home > Article > Backend Development > How to solve php is_writable failure problem
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".
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 = 'test.txt'; if (is_writable($filename)) { echo 'The file is writable'; } else { echo 'The file is not writable'; } ?>
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?
Solution:
chcon -R -t httpd_sys_content_rw_t /var/www/html
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!