Search code examples
javascriptnode.jsnestjsbackendmulter

unexpected filed error in nest js file upload


Hi I am not able to understand what is wrong with below method. it is throwing unexpected field error. even I have changed many files still it is same.

@Post('upload')
@UseInterceptors(FileInterceptor('file'))
uploadFile(@UploadedFile() file: Express.Multer.File) {
  console.log(file);
}

I am calling API using postman. Am I doing any mistake in postman?

enter image description here


Solution

  • it should work like below.

    enter image description here

    you are selecting file but give some name as key. it is blank in your case.