I have this code:
make_file.php:
<?php
// COPYRIGHT Tyler King, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, 2003-2004
echo '<form method="post" action="./submit_make_file.php">
<table width="100%" border="1" cellspacing="0" cellpadding="1">
<tr>
<td bgcolor="#CCCCCC" >
<div align="center"><strong><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif">MAKE FILE</font></strong></div></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif">File name:</font></td>
</tr>
<tr>
<td><input name="filename" type="text" size="49"></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif">File Content:</font></td>
</tr>
<tr>
<td><textarea name="content" type="text" size="49"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>';
?>
submit_make_file.php:
<?php
// COPYRIGHT Tyler King, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, 2003-2004
$file = $_POST["filename"];
$content = $_POST["content"];
$open = fopen($file, 'a+');
fwrite($file, $content);
fclose($open);
echo '<table width="100%" border="1" cellspacing="0" cellpadding="1">
<tr>
<td bgcolor="#CCCCCC">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><strong>INFORMATION</strong></font></div></td>
</tr>
<tr>
<td><font color="#00FF00" face="Verdana, Arial, Helvetica, sans-serif">FILE WAS MADE SUCCESSFULLY</font></td>
</tr>';
?>
But I'm getting this error:
Warning: fwrite(): supplied argument is not a valid File-Handle resource in /mnt/web_h/d38/s15/b01d3464/www/submit_make_file.php on line 13
It has to do with passing the $content variable to fwrite(). Anyone have any ideas on how to remedy?$open = fopen($file, 'a+');
fwrite($file, $content);
That is the problem. In the fwrite function, replace $file with $opentight! that was it. Thanks!!
make_file.php:
<?php
// COPYRIGHT Tyler King, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, 2003-2004
echo '<form method="post" action="./submit_make_file.php">
<table width="100%" border="1" cellspacing="0" cellpadding="1">
<tr>
<td bgcolor="#CCCCCC" >
<div align="center"><strong><font color="#000000" face="Verdana, Arial, Helvetica, sans-serif">MAKE FILE</font></strong></div></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif">File name:</font></td>
</tr>
<tr>
<td><input name="filename" type="text" size="49"></td>
</tr>
<tr>
<td><font face="Verdana, Arial, Helvetica, sans-serif">File Content:</font></td>
</tr>
<tr>
<td><textarea name="content" type="text" size="49"></textarea></td>
</tr>
<tr>
<td><input type="submit" name="Submit" value="Submit"></td>
</tr>
</table>
</form>';
?>
submit_make_file.php:
<?php
// COPYRIGHT Tyler King, <!-- e --><a href="mailto:[email protected]">[email protected]</a><!-- e -->, 2003-2004
$file = $_POST["filename"];
$content = $_POST["content"];
$open = fopen($file, 'a+');
fwrite($file, $content);
fclose($open);
echo '<table width="100%" border="1" cellspacing="0" cellpadding="1">
<tr>
<td bgcolor="#CCCCCC">
<div align="center"><font face="Verdana, Arial, Helvetica, sans-serif"><strong>INFORMATION</strong></font></div></td>
</tr>
<tr>
<td><font color="#00FF00" face="Verdana, Arial, Helvetica, sans-serif">FILE WAS MADE SUCCESSFULLY</font></td>
</tr>';
?>
But I'm getting this error:
Warning: fwrite(): supplied argument is not a valid File-Handle resource in /mnt/web_h/d38/s15/b01d3464/www/submit_make_file.php on line 13
It has to do with passing the $content variable to fwrite(). Anyone have any ideas on how to remedy?$open = fopen($file, 'a+');
fwrite($file, $content);
That is the problem. In the fwrite function, replace $file with $opentight! that was it. Thanks!!