I’m trying to create txt file on fly using php fopen but unable to create it for unknown reason.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hello @pranavkiritkumarsuchak
Just to add on what has already been mentioned, you can also check for any generated PHP
error_log
files in the directory where the .txt file is supposed to be created. This might point in the right direction as well.Regards
Hey @pranavkiritkumarsuchak,
I’m sure the problem is with permissions. Apart from what Bobby has already mentioned I’ll recommend you to check the SELINUX of your Ubuntu.
You can check this tutorial for more information:
https://www.digitalocean.com/community/tutorials/what-is-selinux
Hi there,
You would need to make sure that the Apache user has access to create files in your web root directory.
By default Apache runs as the
www-data
user so you could use:sudo chown www-data /var/www/html
to change the owner of the directory where you want to create your file at.If this still does not work, I would recommend checking your Apache error log for mre infomration on why this is failing:
Let me know how it goes!
Best,
Bobby