Search code examples
node.jsexpressmulter

Image not Uploading while using multer single image input option?


I am using multer to upload single image...

router.post('/register', upload.any(), function(req,res,next){
var img = req.files;
}

If I print the img the it is showing the object properly( originalname, mimeType, size etc) but when i trying to add the propertys in individual variable ( originalname = img.originanae;/req.files.originalename;) then originalname is showing undefined. Why ??


Solution

  • use req.files[0].originalname instead of req.files.originalname