Upgrade & Secure Your Future with DevOps, SRE, DevSecOps, MLOps!
We spend hours on Instagram and YouTube and waste money on coffee and fast food, but won’t spend 30 minutes a day learning skills to boost our careers.
Master in DevOps, SRE, DevSecOps & MLOps!
Learn from Guru Rajesh Kumar and double your salary in just one year.
I am using Linux 16.04 & xampp 5.6.30. I am trying to create a simple login program using file with validation but I am facing problem while putting my data into a file named “login.txt”.
Error
file_put_contents(login.txt): failed to open stream: Permission denied in /opt/lampp/htdocs/PHP/Practice/PHP Functions/Login Validation/login.php on line 38
This error is due to file permissions. The php/apache user does not have the permissions to write in the directory. One way of fixing that is to change the mod byte of the directory with the command chmod
. You need super permissions to execute this modification if your session user does not own the directory.
$ sudo chmod -R 777 /path/to/directory
The mod 777
set read/write and execution to the directory for every user on the system. The R
option applies recursively the modification to every file and sub-directories. So, you can change the permission of all the contents of your htdocs directory all at once.