Click to See Complete Forum and Search --> : Writing to a file


Anon
08-11-2000, 08:54 AM
Hi all, I wonder if anyone can help.

I am trying to take text from a text area in a web page and write that text
into a file on a webserver. That didn't work so I just tried to simply write
a string specified below directly into the file just to see if that would
work

I am using this code but it isn't working and when I check the file it
remains unmodified even the date last modified hasn't changed.

Help would be appreciated,

Thanks,

Hatim.


$newHTMLfile = fopen($newHTMLfilePath,"w+");
fwrite($newHTMLfile, "New text to add to file.");
fclose($newHTMLfile);
echo "new text should be written to file.";

Anon
08-11-2000, 06:17 PM
Are you getting any error messages? Make sure you chmod the file to the correct permissions. Also check that the file was actually opened like this:

if (!$newHTMLfile) {
print("Not able to open");
}

Otherwise, what you have is correct and should work.

Anon
08-15-2000, 11:55 AM
> I am using this code but it isn't working and when I check the file it
> remains unmodified even the date last modified hasn't changed.

Does PHP run in safe mode? Is the user that PHP runs as allowed to write to the file? Are you absolutely sure that the path is correct?


-jani