Page 1 of 1

Saving from a form to a text file problem

Posted: Wed Mar 15, 2006 1:17 pm
by andys22
I am trying to save text from my form into a text file, however I am getting errors. I cannot see a problem with the code:

Code: Select all

<?php
    $data = "wiki_text";
    $filename="wiki.data";
    
    // Open the file for truncated writing 
    $fp = fopen($filename, "w") or die("Couldn't open file for writing"); //this is line 14
    $numBytes = fwrite($fp, $data) or die("Couldn't write values to file!"); 

    fclose($fp); 
  echo "Wrote $numBytes bytes to wiki.data successfully!";
  ?>
It is returning this error:

Warning: fopen(wiki.data): failed to open stream: Permission denied in /public_html/updatewiki.php on line 14
Couldn't open file for writing

Can anyone help me out please? thanks

Andy

Posted: Wed Mar 15, 2006 1:21 pm
by John Cartwright
have you tried chmod(), umask() or chown()

Posted: Wed Mar 15, 2006 1:24 pm
by andys22
I'm a newbie so I have not come across those commands as yet. if you could give me some example of how it might help I will try it. Thanks