Uploading multiple files with multer, but from different fields?
<p>How can I have multer accept files from multiple file type fields?</p>

<p>I have the following code that uploads a single file, using multer in node.js:</p>

<pre><code>var storage =   multer.diskStorage({
  destination: function (req, file, callback) {
    callback(null, './public/uploads');
  },
  filename: function (req, file, callback) {
    callback(null, file.fieldname + '-' + Date.now());
  }
});

var upload = multer({ storage : storage });

app.post('/rest/upload', upload.array('video', 1), function(req, res, next){
    ...
}
</code></pre>

<p>From the following form, on the condition only the video field has a value (if I specify both I get an 'Unexpected field' error):</p>

<pre><code>&lt;form action="/rest/upload" method="post" enctype="multipart/form-data"&gt;
   &lt;label&gt;Video file: &lt;/label&gt; &lt;input type="file" name="video"/&gt; 
   &lt;label&gt;Subtitles file: &lt;/label&gt; &lt;input type="file" name="subtitles"/&gt; 
   &lt;input type="submit"/&gt;
&lt;/form&gt;
</code></pre>

<p>It is not clear from the documentation how to approach this? Any suggestions would be appreciated. BTW I have tried the following parameter variations, without success:</p>

<pre><code>app.post('/rest/upload', [upload.array('video', 1), upload.array('subtitles', 1)] ...
app.post('/rest/upload', upload.array('video', 1), upload.array('subtitles', 1), ...
app.post('/rest/upload', upload.array(['video', 'subtitles'], 1),  ...
</code></pre>