Forum Moderators: coopster

Message Too Old, No Replies

fopen question

         

scorpion

2:55 pm on Apr 27, 2003 (gmt 0)

10+ Year Member



When using fopen and 'w' on a file that exists on a unix system, does the permission of the file have to be 777 to overwrite it? If the file never existed, does it have to be 777 or just the directory has to be 777?

The reason I ask is because I am getting ambiguous behaviour from this. Sometimes it works if just the directory is 777 EVEN if the file exists, sometimes it doesn't work if the preexisting file is not 777.

I am running my script scheduled through a cron job, the only other variable I can imagine is that the permission of that is different and causing problems...any thoughts?

grahamstewart

12:20 am on Apr 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



To write to an existing file, the file itself must be writable (and probably readable as well) so 666 should be ok.

To create a new file the directory must be writable. Not sure if php requires it to be readable and executable, but 777 probably wont do any harm (provided there is nothing sensitive in there and its outside docroot).

bcc1234

1:23 am on Apr 28, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Just make sure it's writable by the www or nobody (depends on how your box is set up).
It's a bit safer than making it world-writable.