title: Uploading multiple files with Multer
body: <p>I'm trying to upload multiple images using Multer. It all works as expected except that only one file is being uploaded (the last file selected).</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;form class='new-project' action='/projects' method='POST' enctype="multipart/form-data"&gt;
    &lt;label for='file'&gt;Select your image:&lt;/label&gt;
    &lt;input type='file' multiple='multiple' accept='image/*' name='uploadedImages' id='file' /&gt;
    &lt;span class='hint'&gt;Supported files: jpg, jpeg, png.&lt;/span&gt;
    &lt;button type='submit'&gt;upload&lt;/button&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>//Define where project photos will be stored
  var storage = multer.diskStorage({
    destination: function (request, file, callback) {
      callback(null, './public/uploads');
    },
    filename: function (request, file, callback) {
      console.log(file);
      callback(null, file.originalname)
    }
  });
  
  // Function to upload project images
  var upload = multer({storage: storage}).any('uploadedImages');
  
  // add new photos to the DB
  app.post('/projects', function(req, res){
    upload(req, res, function(err){
      if(err){
        console.log(err);
        return;
      }
      console.log(req.files);
      res.end('Your files uploaded.');
      console.log('Yep yep!');
    });
  });
  </code></pre>
  
  <p>I get the feeling I'm missing something obvious...</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Code I tried following Syed's help:</p>
  
  <p>HTML</p>
  
  <pre><code>&lt;label for='file'&gt;Select your image:&lt;/label&gt;
  &lt;input type='file' accept='image/*' name='uploadedImages' multiple/&gt;
  &lt;span class='hint'&gt;Supported files: jpg, jpeg, png.&lt;/span&gt;
  &lt;input type="submit" value="uploading_img"&gt;
  </code></pre>
  
  <p>JS</p>
  
  <pre><code>multer = require('multer'),
  
  var upload = multer();
  
  app.post('/projects', upload.array('uploadedImages', 10), function(req, res, err) {
    if (err) {
      console.log('error');
      console.log(err);
    }
    var file = req.files;
    res.end();
    console.log(req.files);
  });
  </code></pre>