1,105,447 Community Members

Can't write output to directory

Member Avatar
ing
Newbie Poster
12 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi. I have a noobish UNIX question.
I have a password-protected section of my website for testing (named 'sandbox') and I'm trying to write output to a plain text file in that directory. But I'm getting the following error due to permissions settings.

Warning: file_put_contents(testdb.txt) [function.file-put-contents]: failed to open stream: Permission denied in /Applications/XAMPP/xamppfiles/htdocs/sandbox/dbtest1.php on line 5

I'm sure it's something simple, but what could I be overlooking?

Member Avatar
rubberman
Senior Poster
3,999 posts since Mar 2010
Reputation Points: 513 [?]
Q&As Helped to Solve: 501 [?]
Skill Endorsements: 87 [?]
 
1
 

It is likely that the attributes on the directory in question don't allow this. You need to enable the read, write, and execute permissions accordingly, assuming that the directory is not owned by the writing process(es).

Member Avatar
ing
Newbie Poster
12 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Thank you.
What does it mean for a directory to be owned by the writing process(es)?

Member Avatar
ing
Newbie Poster
12 posts since Aug 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I just did a chmod 777 on the directory and that fixed everything. :-)

I was concerned that doing so might also recursively change the permissions of the directory's contents (including my .htaccess and .htpasswd files) but it did not.

Member Avatar
L7Sqr
Veteran Poster
1,006 posts since Feb 2011
Reputation Points: 179 [?]
Q&As Helped to Solve: 168 [?]
Skill Endorsements: 11 [?]
 
1
 

While that may not have chnaged things recursively, your original claim of an isolated location is now invalid. That directory is open to all for reading/writing/executing. I'm not sure that matters in your case but you should be aware.

Member Avatar
rubberman
Senior Poster
3,999 posts since Mar 2010
Reputation Points: 513 [?]
Q&As Helped to Solve: 501 [?]
Skill Endorsements: 87 [?]
 
0
 

What L7Sqr said. The attributes you set on the directory means that anyone can, read, write, and access, files there. That may or may not be what you really wanted to do. It doesn't mean that they can modify files that already exist there, though that may be the situation depending upon the user id of the web server process.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
View similar articles that have also been tagged: