Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #11192

Re: file_put_contents not creating file

From The Natural Philosopher <tnp@invalid.invalid>
Newsgroups comp.lang.php
Subject Re: file_put_contents not creating file
Date 2011-02-09 12:00 +0000
Organization albasani.net
Message-ID <iitvl0$psl$2@news.albasani.net> (permalink)
References <d735fda5-fbdd-4adb-a68e-3e691e40ce61@s41g2000vbw.googlegroups.com> <iishra$ukc$1@news.albasani.net> <b7621ea2-f6a2-4c6e-9a5b-a90da3597cd3@v7g2000yqh.googlegroups.com>

Show all headers | View raw


jwcarlton wrote:
> On Feb 8, 5:58 pm, The Natural Philosopher <t...@invalid.invalid>
> wrote:
>> jwcarlton wrote:
>>> Isn't this supposed to append OR create?
>>> $file = "/home/mydomain/users/username/text.dat";
>>> $post = "Test";
>>> file_put_contents($file, $post, FILE_APPEND | LOCK_EX);
>>> What's happening is, if the file already exists, then it appends with
>>> no problem. But if it doesn't, then I'm getting this error:
>>> Warning: file_put_contents(/home/mydomain/users/username/text.dat)
>>> [function.file-put-contents]: failed to open stream: Permission denied
>>> in/home/gowilkes/public_html/test.php on line 58
>>> // Line 58 is the file_put_contents() line
>>> I double checked that the directory path does exist. The permission
>>> set for the directory is 0755, with owner/group set to 32007/32009.
>>> TIA,
>>> Jason
>> So what permissions is PHP running with then? sounds like apache (for
>> example) doesn't have create perms in the directory.
> 
> It looks like PHP (under Apache 2.0.63) is creating as 0644, with
> owner/group set to 99/99. Perl is also creating as 0644, but with
> owner/group set to 32007/32009.
> 
> Most of the text files I'm using are only accessed by PHP, but the
> "private message" section is used by both Perl and PHP, so I'm now
> having a permission issue. I crossed this barrier with Session
> variables that were set by PHP by changing the permission like this:
> 
> $sess_file = "/tmp/sess_" . session_id();
> if (is_file($sess_file)) chmod($sess_file, 0644);
> 
> 
> I'm confused as heck, to be honest. I changed the parent directory to
> 0777, and the Perl script that creates the directories says:
> 
> mkdir("$basepath/$users_path/$user", 0777);
> 
> But still, the new directories that are created are still being set to
> 0755. What??? That's a thread for a different NG, though.
> 

Stickies set on parent directory?

> I guess the question at this point is, how can I modify PHP so that it
> can read files with permission 0644, owner/group = 32007/32009, in a
> directory with permission 0777, o/g 32007/32009?

that should work, for reading.

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

Re: file_put_contents not creating file jwcarlton <jwcarlton@gmail.com> - 2011-02-08 18:49 -0800
  Re: file_put_contents not creating file The Natural Philosopher <tnp@invalid.invalid> - 2011-02-09 12:00 +0000

csiph-web