When learning about PHP File Create/Write functions I have encountered a problem:
Warning: fopen(newfile.txt): Failed to open stream: Permission denied in /opt/lampp/htdocs/someText.php on line 2
Unable to open file!
The code is very simple:
<?php
$myfile = fopen("newfile.txt", "w") or die("Unable to open file!");
$txt = "Hello";
fwrite($myfile, $txt);
fclose($myfile);
?>
How to solve this? I tried to get permission when writing various commands on the Terminal, but whatever I wrote, the Terminal said "no such file or directory".
And finally, I found the solution:
sudo chmod 777 /Users/!YOUR USERNAME HERE!/.bitnami/stackman/machines/xampp/volumes/root/htdocs
Maybe it will be helpful to someone :)