Re: fopen failing, permission denied
| From: | Dan Baker | Date: | Wed, 01 Mar 2006 16:28:23 +0000 |
| Subject: | Re: fopen failing, permission denied | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231264@lists.php.net to get a copy of this message | ||
"Chris" <dmagick@gmail.com> wrote in message
news:4404E180.9020901@gmail.com...
> Dan Baker wrote:
>> I have the following code snippet:
>> $h = fopen("$path/file.txt", 'x+');
>>
>> And it generates the following error:
>> Warning: fopen(/home/...../myarea/file.txt): failed to open stream:
>> Permission denied
>>
>> The path is correct, but the php process doesn't seem to have file
>> permissions in the folder.
>> Is there some magic I can do to allow php to have file rights to the
>> "myarea" folder? (This is on a purchased ISP site)
>
> Go in through ftp or ssh and fix the permissions.
>
> If you only want to read the file, then it only needs to be 644.
>
> If you need to write the file it will either need to be 646 or 664.
>
> That's your only option apart from deleting the file (through ftp) and
> recreating it through your php script ... or getting your host to change
> to the CGI version of php which is most unlikely to happen.
I'm actually trying to create the file (thus the 'x+' mode). The file
doesn't exists. It appears to me that the php process doesn't have
permission to the entire folder. My ftp client has full access to the
folder ("myarea"), but the php process doesn't. The folder is under the
http folder. I'll check if I can alter the permissions on the "myarea"
folder.
DanB