title: Node.js 344 error Can't set headers after they are sent
body: <p>Trying to wrap my head around this error I get, I don't understand why. I seen a couple of posts with it, but they are all different cases and none kinda match mine. So appreciate help.
  what i want to upload multiple files upload.
  but I do file upload It's work just one.
  but when i try to upload multiple files, it's not working
  can you give me a answer?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>router.post('/contents/insert/upload', ensureAuthenticated, function(req, res, next) {
   
   var form = new formidable.IncomingForm();
   
   form.parse(req);
  // form.on("fileBegin", function (name, file){
  //  console.log('upload come on3');
  //  
  //    });
      form.on("file", function (name, file){
          fs.readFile(file.path, function(error, data){
           var filePath = __dirname + '/../public/uploads/' + file.name;
           
           fs.writeFile(filePath, data, function(error){
            if(error){
             throw err;
             //res.redirect('back');
            }else {
             res.redirect('back');
            }
           });
          });
      });
  
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;form action="/adm/contents/insert/upload" method="post" enctype="multipart/form-data" &gt;
         &lt;!-- &lt;input type="file" name="file" /&gt;
         &lt;input type="submit" /&gt; --&gt;
      &lt;div class="file-field input-field"&gt;
          &lt;div class="btn"&gt;
        &lt;span&gt;input images&lt;/span&gt;
           &lt;input type="file" name="file" multiple&gt;
          &lt;/div&gt;
            &lt;div class="file-path-wrapper"&gt;
              &lt;input class="file-path validate" type="text"&gt;
            &lt;/div&gt;
         &lt;/div&gt;
         &lt;input type="submit" class="btn waves-effect waves-light" value="upload" /&gt;
     &lt;/form&gt;</code></pre>
  </div>
  </div>
  </p>