PHP file_put_contents(x.txt): failed to open stream: Permission denied

Viewed 23

Im currently coding a little project for my school work. It goes like this, i have one index page, you get the option to register classes or students, or view them. When i click register classes, fill out the names and click submit,

'file_put_contents(klasse.txt): failed to open stream: Permission denied'

but prints out the message that gives after its supposed to be done. I dont know how to fix this, any solutions? Im coding on VSC and using HTML/PHP for this, also im using my school web order to post my coding and thats where i been testing it and getting these results. Thanks in advance.

1 Answers

try this ( for unix OS )

chmod 750 /path/to/klasse.txt

if you are using apache as web server :

chown apache:apache /path/to/klasse.txt

if not change 750 to 777 (bad recommendation)

Related