I am trying to create a file in php and after the file run they get error(failed to open stream).and my php code is:-
<?php $fileLocation = getenv("DOCUMENT_ROOT") . "/myfile.txt"; $file = fopen($fileLocation,"w"); $content = "Your text here"; fwrite($file,$content); fclose($file); ?>
how can i fix the error.
It is a permission error.
You don't have right to create file at the location you are trying to create, it means the user from which you are logged in doesn't have that right.
Try chmod 777 /path/to/file if you are using Unix like Operating Sytem also try changing the User.