title: Can't parse form-data twice
body: <p>What I am trying to do is delete the images with same id before I upload a new image, if the user has inputed image. Multer does not provide a way to detect if there is an input only, it has to upload the file first.</p>
  <p>So I figured out to use another form-data libarary to do just that. But when I do that multer doesn't recieve the form-data to upload. So it doesn't upload anything. The image only get delete, but no new images are added.</p>
  <p><strong>The problem</strong> is I can't parse for data twice. How can i fix it? Or is there a workaround?</p>
  <p><strong>Code explination</strong></p>
  <p>I am using multyparty to detect if the user has included an image in a form.</p>
  <pre class="lang-js prettyprint-override"><code>form.parse(req, async (err, fields, files) =&gt; {
      if (err) console.log(err);
      else if (files.image) removeImagesWithSameId(req.params.id)
  });
  </code></pre>
  <p>If there an image in the form then delete the previous uploaded image</p>
  <pre class="lang-js prettyprint-override"><code>const removeImagesWithSameId = (id) =&gt; {
      fs.unlink(__dirname + id + &quot;.jpg&quot;, (err) =&gt; {
          if (err) console.log(err)
  
          console.log(&quot;image Delete&quot;)
      })
  }
  </code></pre>
  <p>Then upload the new image, using multer.</p>
  <pre class="lang-js prettyprint-override"><code>upload(req, res, (err) =&gt; {
      if (err) console.log(err)
      else if (req.file) console.log(&quot;Image uploaded&quot;)
  });
  </code></pre>
  <p>Execpt the new image not getting uploaded, because multer not receiving the data and <code>req.file</code> is undefined.</p>
  <p>My questions is why multer is not receiving the data when ever I add multiparty, and how to fix it?</p>
  <hr />
  <p>Whole the code</p>
  <pre class="lang-js prettyprint-override"><code>const express = require('express');
  const app = express();
  const multiparty = require('multiparty');
  const form = new multiparty.Form();
  var upload = multer({ dest: __dirname }).single('image');
  
  const removeImagesWithSameId = (id) =&gt; {
      fs.unlink(__dirname + id + &quot;.jpg&quot;, (err) =&gt; {
          if (err) console.log(err)
  
          console.log(&quot;image Delete&quot;);
      })
  }
  
  app.post('/upload/:id', (req, res) =&gt; {
      form.parse(req, async (err, fields, files) =&gt; {
          if (err) console.log(err);
          else if (files.image) removeImagesWithSameId(req.params.id)
      });
  
      upload(req, res, (err) =&gt; {
          if (err) console.log(err)
          else if (req.file) console.log(&quot;Image uploaded&quot;)
      });
  })
  </code></pre>
  <p><strong>Note</strong> this is only demonstration of the probelm. My actaul code is bit longer then that.</p>
  <p>For people who is asking about the requst, I am using nodemon, but this equivalent curl requst.</p>
  <pre class="lang-sh prettyprint-override"><code>curl --location --request PUT 'localhost/upload/1593735936343' \
       --form 'image=@/C:/Users/Hamza/images/test.jpg'
  </code></pre>