I have my head around Jquery now but want to save a text area to a txt file. With the ultimate goal as being able to upload a text file to the same place as well. What am I missing in my code?
Not sure where I am define the textarea in this code or whether it should be in another file or if the html file should have the suffix of php?
Cheers below is my attempt at the php.
CODE
<?php
if(isset($_POST['submit_save'])) {
$file = "output.txt";
$output = $_POST['output_str'];
file_put_contents($file, $output);
$text = file_get_contents($file);
header("Content-type: application/text");
header("Content-Disposition: attachment; filename=\"$file\"");
echo $text;
}
else
{
$_POST['output_str'] = "";
}
?>
</head>
<body>
<input id="submit_save" type="button" value="save" />
</br></br></br>
<div id="opt"></div>
</body>
</html>