View Full Version : fwrite - chmod

12-28-2006, 10:10 AM
A standard file write routine - generating the file $fname on the first run.

$fh = fopen($fname, 'w');

On the current server the file, $fname, is written with permission and status:
-rw-r--r-- www-data
So... trying to later write to the file doesn't work.
Being www-data it resists standard fTP chmod command.
It also fails:
chmod("$fname", 0666);

Any suggestions or comments here would be most welcome.


12-28-2006, 10:21 AM
I'm a little confused about your question. What are you trying to do? Just use fopen again to write to the file again. To write to a directory the permissions need to be set to 770 or 777. I think 770 is the safer method.

12-28-2006, 09:48 PM
I now see that my php chmod script was giving errors - but only for directories.

Easy to test for is_dir and skip.

Yes, 770 is enough - and adds a bit of extra security.