sssweb - 8:13 pm on Jun 12, 2012 (gmt 0)
I just got this working. The solution is pretty easy so here it is for others with the same issue:
1. using ftp, change file permissions for the directory ABOVE the directory in which you want the files to 757
2. use PHP mkdir("directory/path", 0755) to create the directory within the one from step 1
3. PHP chmod("directory/path", 0757) [note - you can try combining steps 2 & 3 with mkdir(..., 0757), but my server didn't allow it]
4. PHP file_put_contents() to create and write the file in the directory PHP created
5. PHP chmod("directory/path", 0755)
6. *** Remember to ftp the directory in step 1 back to 755
Thereafter, you should be able to create, write to, and update files in your PHP-created directory.
In short, php can only chmod to folders and files that it creates, so set permissions to 757 via ftp, let php create the directory, then php can chmod back & forth as needed when writing.
If anyone sees a problem with this fix, please post for my benefit and others.