fopen Permission denied
I have a php file in a folder.
this file is being called by cron and trying to perform fwrite() on a file in this same folder.
I am supplying the full path to the file $filepath = $_SERVER['DOCUMENT_ROOT] . '/file'; I've checked that it returns the correct absolute path to the file I want to open.
I've tried every imaginable owner:group and set of permissions, 666, 777.
this is php7.2 on Centos7 allow_url_fopen is enabled suphp handler get_current_user() is the owner of the account any ideas would be welcome. the full cascade of errors is
The code that generates the errors is
fopen($filepath): failed to open stream: Permission deniedthis is php7.2 on Centos7 allow_url_fopen is enabled suphp handler get_current_user() is the owner of the account any ideas would be welcome. the full cascade of errors is
[10-Aug-2020 23:53:01 America/Toronto] PHP Warning: fopen(/.htaccess): failed to open stream: Permission denied in /home/myaccount/mydomain/redirect.php on line 46
[10-Aug-2020 23:53:01 America/Toronto] PHP Warning: fwrite() expects parameter 1 to be resource, boolean given in /home/myaccount/mydomain/redirect.php on line 47
[10-Aug-2020 23:53:01 America/Toronto] PHP Warning: fclose() expects parameter 1 to be resource, boolean given in /home/myaccount/mydomain/redirect.php on line 48
The code that generates the errors is
$filepath = $_SERVER['DOCUMENT_ROOT'>.'/.htaccess';
$fh = fopen($filepath, 'w');
fwrite( $fh, $content );
fclose($fh);
-
Thanks, that's it. 0 -
Thanks @Okaro for helping out with this one! 0 -
The same thing happened to me a couple of years ago and it was very frustrating.... :-p:-p:-p 0
Please sign in to leave a comment.
Comments
4 comments