Monday 23 September 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

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...