Reputation: 3
I'm trying to write to file, but PHP tells me that it's forbidden.
I tried to change permissions, assigned files to group 'apache' (according to <?php echo whoami(); ?>
), but it didn't work.
Here is result of my file:
phpversion: 5.4.16
uname: Linux
exists // echo file_exists($file) ? ' exists' : ' does not exist', "\n";
is readable // echo is_readable($file) ? ' is readable' : ' is NOT readable', "\n";
is NOT writable // echo is_writable($file) ? ' is writable' : ' is NOT writable', "\n";
Warning: fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied in /var/www/html/test/test.php on line 23
last error: array(4) {
["type"]=>
int(2)
["message"]=>
string(87) "fopen(system/cache/cache.currency.1417623063): failed to open stream: Permission denied"
["file"]=>
string(30) "/var/www/html/test/test.php"
["line"]=>
int(23)
}
Can you help me, please?
Upvotes: 0
Views: 2232
Reputation: 3
It was SELinux. It blocked all file changes, so I was able to read, but not write.
Upvotes: 0
Reputation: 675
Which fopen mode you set? to read file enought fopen("/var/www/html/test/test.php", "r");
Upvotes: 1