Answer the question
In order to leave comments, you need to log in
How to save data from html form to computer?
Good day
I want to upload data from the html form to a text file on the local machine. I've already tried a lot of things - it doesn't help:
1. require(fs) does not work in the browser, as I understand it
2. require(browserify-fs) saves the file, but in virtual memory, again, if I understand correctly
3. the only way out is - php a script that for some reason does not want to work. Trying to fix - in vain (complete zero in php)
program.php
<?php
$title = $_POST["channel0Title"]; //You have to get the form data
$gain = $_POST["channel0Gain"];
$offset = $_POST["channel0Offset"];
$file = fopen('1.txt', 'w'); //Open your .txt file
ftruncate($file, 0); //Clear the file to 0bit
$content = $title. PHP_EOL .$gain. PHP_EOL .$offset;
fwrite($file , $content); //Now lets write it in there
//file_put_contents($file , $content);
fclose($file ); //Finally close our .txt
die(header("Location: ".$_SERVER["HTTP_REFERER"]));
?>
<form action="public\scripts\program.php" method="post">
Channel 8 Title:<br><input type="text" name="channel0Title" value="Channel 7"><br>
Gain:<br><input type="text" name="channel0Gain" value="4.000"><br>
Offset:<br><input type="text" name="channel0Offset" value= "6.000"><br>
<input type="submit" id ="submitButton" value="Submit">
</form>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question