2
我想要每個html表單提交都創建它自己的時間戳文件,但是當表單第二次提交時,它會被新的時間戳覆蓋。我應該把它放在一個循環中嗎?nodejs表單數據被覆蓋
app.use(bodyParser.urlencoded({ extended: true }));
app.post('/myaction', function(req, res) {
res.send('Thank you for your inquiry, someone will contact you shorty.');
fs.writeFile(timeEntry+'submission.txt', req.body.businessname, function(err) {
if (!err) {
console.log('Wrote data to file.txt');
} else {
throw err;
}
});
fs.appendFile(timeEntry+'submission.txt', req.body.contactname, function(err) {
if (!err) {
console.log('Wrote data to file.txt');
} else {
throw err;
}
});`
它的工作原理,謝謝! –