Reputation: 129
I have a User object in my application, where each user Object has a Nominee as a child object With a File field name photo.
{
name: 'Jhon Doe',
phone: '01548761645',
email: '[email protected]',
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
}
In my express code i can access all file details for Parent Object but it did not show any details for child(nominee) Object. Is there anything wrong in my code or multer did not support nested child field..?
Upvotes: 3
Views: 1219
Reputation: 41
I know it's a bit late but
upload.single('nominee[photo]')
Should do the job
Upvotes: 4