fopen() fails to open stream: permission denied, yet permissions should be valid

Posted by about blank on Stack Overflow See other posts from Stack Overflow or by about blank
Published on 2012-09-07T03:18:08Z Indexed on 2012/09/07 3:38 UTC
Read the original article Hit count: 189

Filed under:
|
|
|
|

So, I have this error:

Warning: fopen(/path/to/test-in.txt) [function.fopen]: failed to open stream: Permission denied

Performing ls -l in the directory where test-in.txt is produces the following output:

-rw-r--r-- 1 $USER $USER 1921 Sep  6 20:09 test-in.txt
-rw-r--r-- 1 $USER $USER    0 Sep  6 20:08 test-out.txt

In order to get past this, I decided to perform the following:

chgrp -R www-data /path/to/php/webroot

And then did:

chmod g+rw /path/to/php/webroot

Yet, I still get this error when I run my php5 script to open the file. Why is this happening? I've tried this using LAMP as well as cherokee through CGI, so it can't be this.

Is there a solution of some sort?

Edit

I'll also add that I'm just developing via localhost right now.

Update - PHP fopen() line

$fullpath = $this->fileRoot . $this->fileInData['fileName'];

$file_ptr = fopen( $fullpath, 'r+' );

I should also mention I'd like to stick with Cherokee if possible. What's this deal about setting file permissions for Apache/Cherokee?

© Stack Overflow or respective owner

Related posts about linux

Related posts about php5