Monday, September 23, 2019

Permission denied when opening or creating files with PHP








I can't create files with php, because the file dosent got permission for that.
I get this error:




Warning: fopen(test.txt): failed to open stream: Permission denied in /web/com/example.com/index.php on line 20
Warning: fwrite() expects parameter 1 to be resource, boolean given in /web/com/example.com/index.php on line 21
Warning: fclose() expects parameter 1 to be resource, boolean given in /web/com/example.com/index.php on line 22





This is the code I was using:



 $file = fopen("test.txt","w");
echo fwrite($file,"Hello World. Testing!");
fclose($file);
?>



Simple as that! This is example code from w3schools.



So I need help to find out how to give the file the needed permissions.
I'm uploading files to my site with the net2ftp FTP web application, if it matters.

No comments:

Post a Comment

hard drive - Leaving bad sectors in unformatted partition?

Laptop was acting really weird, and copy and seek times were really slow, so I decided to scan the hard drive surface. I have a couple hundr...