[英]i want to take the data from html page and store in a file as json data in node.js
The following is my html code i want to read the file ans store the data in a file using node.js 以下是我想读取文件的html代码,并使用node.js将数据存储在文件中
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title>The Page Returned by Making Http Call to Node.js</title>
<style type="text/css">
table, td {
border:double;
}
</style>
</head>
<body>
<h1>Product Information Page</h1>
<table>
<tr>
<td>Product Id:</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td>Product Name:</td>
<td>
<input type="text" />
</td>
</tr>
<tr>
<td></td>
<td>
<input type="button" id = "textFieldId" value="Save"/>
</td>
</tr>
</table>
</body>
</html>
The following is my Node.js code i want to write the user input text fields to my filesystem 以下是我想将用户输入文本字段写入我的文件系统的Node.js代码
app.get('/list_user', function (req, res) {
res.sendFile(path.join((__dirname + '/AppPages/MyPage.html')))
let inputContent = res.body;
console.log(inputContent);
JSON.stringify(inputContent);
fs.writeFile(__dirname+'/AppPages/data.json',inputContent,function(err){
if (err) throw err;
console.log('saved')
})
I am getting in data.json as undefined 我进入data.json作为未定义
在代码中没有初始化数据对象的位置,但是看起来可以输入内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.