I have a simple form with two file input fields. One is about an image, and the other is about a mp3 file.
I have an express server which utilizes multer as file upload system. I'd like to save the image inside the img
, and the mp3 file inside the music
folder.
This is what I tried so far:
var musicUpload = multer({dest: 'music'});
var imgUpload = multer({dest: 'img'});
app.post('music',
musicUpload.single('music'),
imgUpload.single('img'),
function (req, res) {
...
});
While this is the form:
<form action="post" enctype="multipart/form-data" action="music">
<input type="file" id="img" name="img">
<input type="file" id="music" name="music">
<input type="submit" value="Send">
</form>
I need to handle the 2 different files in a different way, this is the reason why I used "single" twice. But, unluckly, I receive a "Unexpected field" error message.
How can achieve the result?
Ps. There are many question on SO about multiple files uploading, but none of them solved my specific problem. Don't be too much fast at flagging this question :)