I’m working with an API that gives JSON. I want to save the contents of the API request to a file called cache.json, but it seems I don’t have the permissions.
$f = fopen("cache.json", "w") or die("Failed to open file"); fwrite($f, $output); fclose($f);
I made sure to make cache.json owned by www-data, but that didn’t seem to work.
$ ls -l total 136 -rwxrwxrwx 1 www-data www-data 0 Feb 24 09:39 cache.json
PHP Warning: fopen(cache.json): failed to open stream: Permission denied in /var/www/flag/server/abuseipdb.php on line 19
How can I fix this?