Re: fopen failing, permission denied
| From: | Dan Baker | Date: | Wed, 01 Mar 2006 21:04:49 +0000 |
| Subject: | Re: fopen failing, permission denied | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231281@lists.php.net to get a copy of this message | ||
(SOLVED, see below)
"Dan Baker" <dbefc@furiousgames.com> wrote in message
news:du4i38$ppt$1@sea.gmane.org...
> "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.
I took the suggestion from Chris, and checked the permissions on the
"myarea" folder. They were set so others could NOT "write". I added this
permission, and everything works great now!
Thanks for the pointer Chris
DanB