I am using node and express for backend and Mongo DB for storage.I am using multer middleware for storing image,i got a problem and the problem is when i store an image from
var dateString = Date.now(); var storage = multer.diskStorage({
destination: (req, file, cb) => {
cb(null, './uploads/')
},
filename: (req, file, cb) => {
cb(null, dateString+'_'+file.originalname)
}
});
var maxSize=3 1000 1000;
var upload = multer({ storage: storage,
limits: { fileSize: maxSize }})
var upload = multer({ storage: storage , limits: { fileSize: maxSize }});
app.post("/fileupload", upload.single("fileToUpload"), function (req, res) {
console.log(req.file.originalname)
var uploaded = "http://localhost:4001/"+dateString+'_'+req.file.originalname;
console.log(uploaded)
res.json({status: 200,msg:'File saved successfully',data:uploaded});
});