When trying to create a JSON file with fopen
me, a permission error is returned with the following message:
Warning: fopen (/json/9.json): failed to open stream: No such file or directory in C: \ xampp \ htdocs \ apil \ Controllers \ Classex.php on line 120
As I use the Windows operating system, I have already given permission on the folder that I left pre-created, however, the problem still persists.
Permission I gave everyone on the JSON file by right-clicking on the file-> Properties-> Share:
ThecodeI'musingtoperformthefilecreationandlatersavethedatatoitfollows:
protectedfunctionfilejson($product_id,$account_id){$file=array($account_id);$json=fopen("/json/" . $product_id . ".json", "w");
fwrite($json, json_encode($file));
fclose($json);
}
And I call the method in another method that is in the same class as follows:
Classex::filejson($product_id, $this->getAccount_id());
It should be noted that both $product_id
and $account_id
faces have the correct content or are not null.
I'm using XAMPP in Windows 10.