title: multiple file upload not working with formidable in node js
body: <pre><code>app.post('/upload', function (req, res) {
      var form = new formidable.IncomingForm();
      form.parse(req, function (err, fields, files) {
        try{
          if (files.file.name != '') {
            file_newname = dt.MD5(files.file.name + Date() + Math.random()) + '.jpg' + ;
            var file_newpath = './tmp/' + file_newname;
            fs.readFile(file_oldpath, function (err, data) {
  
              // Write the file
              fs.writeFile(file_newpath, data, function (err) {
                console.log('File written!');
                res.end(JSON.stringify({             
                  message: 'file uploaded successfully'
                }));
              });            
  
            });
          }
        }catch (e) {
  
        }
      });
    });
  </code></pre>
  
  <p>The single image upload is working perfectly.I tried the following code</p>
  
  <pre><code>var form = new formidable.IncomingForm();
  
  
  
  files = [],
  fields = [];
  form.on('field', function(field, value) {
      fields.push([field, value]);
  })
  form.on('file', function(field, file) {
      console.log(file.name);
      files.push([field, file]);
  })
  form.on('end', function() {
      console.log('done');
      //res.redirect('/forms');
  });
  form.parse(req);
  </code></pre>
  
  <p>But only a single image gets uploaded.  i m using react in frontend. Node and express in backend.</p>
  
  <p>I also tried multer. But that doesnt working</p>
  
  <pre><code>app.post('/getrast', upload.array('files'), function (req, res) {
  
       res.json({data: req.files});
       });
  </code></pre>