Uploading multiple files through form from different fields and storing into mongodb databse using express multer Uploading multiple files through form from different fields and storing into mongodb databse using express multer mongoose mongoose

Uploading multiple files through form from different fields and storing into mongodb databse using express multer


I have taken your code and debug it.At my end i have used 4 images(2 of them having size in KB and 2 are 9-10 MB) for testing purpose and found that problem exist when either one or both input file of large size(MBs).so,in uploadDB method you've created two instance of Cast model and then save it.to solve your problem create one instance save it and then create second instance and save it.

const actor = new Cast({            name: req.body.actor,            image: req.files.uplactor[0].filename        });        await actor.save();        console.log(req.files.uplactress[0]);        const actress = new Cast({            name: req.body.actress,            image: req.files.uplactress[0].filename        });        await actress.save();

hope this might help

Output:Output