【发布时间】:2016-11-20 02:59:23
【问题描述】:
我正在尝试使用 put 请求更新数据
我使用方法覆盖包和 multer 进行文件上传
我无法弄清楚是什么导致了问题,因为
我的发布路线工作正常,其中对象从 req.body 字段存储在数据库中并且文件正在上传
这是我的路线:
app.put("/browse/:id", function(req, res){
console.log( req.body); // returns empty object
console.log( req.file); //undefined
})
这是表格
<form action="/browse/<%= book._id %>?_method=PUT" enctype="multipart/form-data" method="POST">
<input value="<%= book.image %>" type="file" name="image" >
<input value="<%= book.title %>" type="text" name="title" required>
<textarea name="desc">
<%= book.description %>
</textarea>
<button class="btn btn-success" type="submit"> Update </button>
</form>
【问题讨论】:
标签: node.js mongodb express mongoose