我的应用程序中有一个User对象,其中每个用户Object都有一个Nominee作为子对象,文件字段名称为photo。
{
name: 'Jhon Doe',
phone: '01548761645',
email: 'jhon@email.com',
photo: File(),
nominee: {
name: 'Nominee name',
phone: '9876546542',
photo: File()
}
}
app.post(upload.fields([{name:'photo'}, {name:'nominee'}]), function(req, res) {
res.send(req.files['photo']); // send file details
res.send(req.files['nominee']); // did not show any file details
}
app.post(upload.fields([{name:'photo'}, {name:'nominee.photo'}]), function(req, res) {
res.send(req.files['photo']); // send file details
res.send(req.files['nominee.photo']); // did not show any file details
}
在我的快速代码中,我可以访问父对象的所有文件详细信息,但它没有显示子(nominee)对象的任何详细信息。我的代码有什么问题,或者multer不支持嵌套的子字段..?
答案 0 :(得分:1)
我知道有点晚了,但是
upload.single('nominee[photo]')
应该去做