【发布时间】:2015-05-13 09:53:01
【问题描述】:
我正在使用 node、express、html 并且我正在尝试使用 html 表单将 a 发布到我的服务器端。 问题是我将 {} 作为我的 req.body。
我的html表单如下:
<form method = 'post' action='get_name' enctype="multipart/form-data">
<input type="text" name="form_name"><br>
<input type="submit" value="Upload name">
</form>
我在 node.js 文件的开头使用以下内容:
app.use(bodyParser.urlencoded({limit:'5mb', extended:false}));
app.use(busboy());
我的 app.post 如下:
app.post('/get_name',function(req, res, next){
console.log("the name of the form is : ", req.body);
res.redirect('/admin');
});
当我试图获取 req.body.form_name 时,我得到了未定义。我无法找出我的代码有什么问题。欢迎任何建议。 :)
【问题讨论】:
标签: html node.js forms express