i want to do following: when user uploads file with form fields too check if form fields are empty, and if it is do not upload file. and i am using this code
fileFilter: (req,file,callback) =>{
if(req.body.name.trim().length < 1){
callback(null, false)
}
}
but it gives me undefined for req.body.name and as i know fileFilter takes Express.Request as first argument and then why i can not access body?
full error
TypeError: Cannot read property 'trim' of undefined
Thanks!