Skip to content Skip to sidebar Skip to footer

How To Fix "multererror: Unexpected Field" In A Nodejs Express Server?

I'm setting up a server to upload zip files from the client. The server runs with express and multer to do this. When uploading a file, the server throws a 'MulterError: Unexpected

Solution 1:

In the code

app.post('/upload', multer(multerConfig).single('photo'),function(req, res){
      //Here is where I could add functions to then get the URL of the new photo//And relocate that to a cloud storage solution with a callback containing its new URL//then ideally loading that into your database solution.   Use case - user uploading an avatar...
      res.redirect('complete.html');
  }

I was putting the value single('photo'), when in the HTML form I sent, a 'zip' value in there. Changing that made the code work as expected :)

Post a Comment for "How To Fix "multererror: Unexpected Field" In A Nodejs Express Server?"