That is what I have in my script but I get this error ...
Warning: fopen("test.txt", "w") - Permission denied in /home/virtual/site54/fst/var/www/html/awritetest.php on line 5
The script is running as nobody (if I am thinking right) and I think that is where my problem lies. If a file exists, it seems that I can overwrite it but if it is a new file, I get the above error.
The only way that I have come up with to get around it is to create the directory with everyone having write privs (the part that I don't like) for a short period of time while I create the necessary files and then change it back. I toyed with umask but wasn't successful.