LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   php : fopen() with 'w' option (https://www.linuxquestions.org/questions/linux-software-2/php-fopen-with-w-option-930427/)

buzzport 02-21-2012 12:41 AM

php : fopen() with 'w' option
 
Hi,

I keep getting the "permission denied" error message. Can someone help me fix this problem I am having with my PHP script
( please see below )?



I have read a few forums, and tried the suggested fixes, but still can't get it to work.

Any suggestions?

operating system:
linux 16

Version of php:
5.3.10

line of code:
fp = fopen( "$DOCUMENT_ROOT/testfile/testfile.txt", "w" );

DOCUMENT_ROOT = /var/www/html

error message:
[Tue Feb 21 01:10:49 2012] [error] [client 127.0.0.1] PHP Warning: fopen(/var/www/html/testfile/testfile.txt): failed to open stream: Permission denied in /var/www/html/processorder.php on line 108, referer: http://localhost/orderform.html


file permission settings:
drwxr-xr-x. 21 root root 4096 Dec 15 10:14 var
drwxr-xr-x. 8 root root 4096 Dec 15 10:12 www
drwxr-xr-x. 3 root root 4096 Feb 21 01:09 html
drwxrwxrwx. 2 apache root 4096 Feb 21 01:08 testfile
-rwxrwxrwx. 1 apache root 0 Feb 20 07:59 testfile.txt

buzzport 02-21-2012 12:47 AM

Also, I tried chown root testfile etc.
but, received same error message:

rwxrwxrwx. 2 root root 4096 Feb 21 01:08 testfile
-rwxrwxrwx. 1 root root 0 Feb 20 07:59 testfile.txt


All times are GMT -5. The time now is 11:52 PM.