Why "not rewritable"? I try to modify txt-file but get "not writable". I've tried to chmode Help :-)
Apr 28th, 2004 16:13
Mike Chavez, Paul Dunkel,
This happened to me once, not sure if you're suffering from the same
problem though, so bear with me:
I created a file using appened mode:
$visits = fopen("./_private/visits.log", "a");
Then I wrote some info to it and closed the file. When I opened the
file in Pico though and tried to erase some entries manually. It came
up with "File not writable!". After trying to chmod it (and all
failures) I found out the problem:
When php creates a file, it is assigned the group ownership "nobody"
and the owner "nobody" and Linux sets file permissions as such. Read
only for everyone, and write permissions only when the file is created
in PHP. Since you probably belong to a group (mine was webscripting)
and have a username (mine was mchavez) you get the dillemma:
user "mchavez" from group "webscripting" wants to change the
file "visits.log" which belongs to "nobody" in the group "nobody". So,
I as Linux say "CHMOD failed!"
Once the script is done, the permissions are changed back to prevent
tampering. The only way I saw around this is to create a blank file
and set the permissions yourself, then open the file using "r+" or "w".