PHP fopen error-Unable to open stream


In a PHP file, I am trying to make a JSON file using the fopen command.

 $id = mysqli_insert_id();

I get the error message

Warning: fopen(/village/user_data/4.json): failed to open stream: No such file or directory in /home/ubuntu/workspace/village/php/server.php on line 60
Do I have to grant PHP access to create/write files, am I incorrectly using parent directory `/`?


You have to set allow_url_fopen to 1 in the php.ini

ini_set(“allow_url_fopen”, 1);