Page 1 of 1

Problem in File Handling in PHP

PostPosted: 21. July 2014 10:37
by KS_Sahil
Hi Guys!

I am using Ubuntu 12.04 and in that I have installed XAMPP 1.8.2-5.
When I am doing the file handling in PHP, the new file (by using fopen()) is not created. I don't know why but it says permission denied to open the file.
At first I thought this is the issue of root permission. But even after logging in as root, it is not working.
Please suggest some way to overcome this problem.

Thanks in advance!

Re: Problem in File Handling in PHP

PostPosted: 21. July 2014 10:47
by Nobbie
KS_Sahil wrote: But even after logging in as root, it is not working.


Of course not.

Your own login and/or UserID is not relevant for Apache and PHP, Apache is a system process which runs under a certain UserID, which is determined by the option "User = ...." in httpd.conf. As PHP runs as module under Apache, it runs with the same UserID.

Obviously, this UserID does not have sufficient rights to create a new file in the desired folder. Thats all - you have to change the rights of the folder (via "chmod") or change the ownership of that folder (via "chown") in order to allow Apache/PHP to create files.