Tuesday 26 January 2016

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

c++ - Does curly brackets matter for empty constructor?

Those brackets declare an empty, inline constructor. In that case, with them, the constructor does exist, it merely does nothing more than t...