The situation is, I have written some code in PHP to write JSON file in the server(Lighttpd) the code is
'''<?php
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
function get_data() {
$datae = array();
$datae[] = array(
'Name' => $_POST['name'],
'Branch' => $_POST['branch'],
'Country' => $_POST['country'],
);
return json_encode($datae);
}
$name = "gfg";
$file_name = $name . '.json';
if(file_put_contents(
"$file_name", get_data())) {
echo $file_name .' file created';
echo "<br><br><br><br><a href='get.html'>view data</a>";
}
else {
echo 'There is some error';
}
}
?> '''
this same code works fine with Apache servers. I have giver permissions as 777 to www folder
the error log of Lighttpd is 2022-10-13 09:50:13: (mod_fastcgi.c.451) FastCGI-stderr:PHP Warning: file_put_contents(gfg.json): Failed to open stream: Permission denied in /var/www/html/web/www/pc/a/gfg.php on line 18
any help will be appreciated