Page 1 of 1

write a variable from form to file AND create file in dir.

Posted: Wed Jul 23, 2003 12:06 pm
by mesz
I'm trying to write a variable from a form to a specified file AND also to create a file in a directory.
Is this even possible?
I have read php.net and fwrite seems to suggest this is possible, but nearly every clue seems to end up in writing a variable to a specified file rather than actually creating a file in a specified directory.
Here is waht I tried.

Code: Select all

<?
$testdir = "./test1/"; 
$test = fopen($testdir,'a+'); 
$fp = fopen('news.dat','a+'); 
if (!$fp) { 
echo "Sorry could'n open file!<br>"; 
} else { 
if($HTTP_POST_VARS['submit']) 
        $testdir = "./test1/"; 
$test = fopen($testdir,'a+'); 
$fp = fopen('news.dat','a+'); 
           $line .= "|" . $HTTP_POST_VARS['news'];
                      $line .= "\r\n";
        fwrite($test, $fp, $line);
       }
?>
Error:
It is all bobbins!

Posted: Wed Jul 23, 2003 1:37 pm
by mesz
I have solved :D this in part - probably posted my question far too early in desperation!
For any one elses' information you might want to try the http://uk.php.net/function.touch and umask functions of http://www.php.net
Cheers