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?

Recommended Answers

All 5 Replies

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).

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

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.

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.

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.