title: React axios multiple files upload
body: <p>I'm trying upload multiple images with axios in React but i cannot figure out what is wrong. First I tried to upload single image and that work just fine. But with multiple images I'm out of options.</p>
  
  <p>I'm creating FormData like so:</p>
  
  <pre><code>for (let i = 0; i &lt; images.length; i++) {
      formData.append('productPhotos[' + i + ']', images[i]);
  }
  </code></pre>
  
  <p>The axios request looking like this</p>
  
  <pre><code>    const config = { headers: { 'Content-Type': 'multipart/form-data' } };
  
      axios
          .post(endPoints.createProduct, formData, config)
          .then(res =&gt; console.log(res))
          .catch(err =&gt; console.log(err));
  </code></pre>
  
  <p>My back-end is written is node/express and I'm using multer for uploading. The signature is look like this:</p>
  
  <pre><code>app.post("/product", upload.array("productPhotos"), (req, res) =&gt; {
  </code></pre>
  
  <p>I tried this back-end end point in PostMan and uploading works for just fine, so the error must be on front-end. Thanks for help.</p>
  
  <p><strong>UPDATE</strong>
  Right way to pass multiple files in formData:</p>
  
  <pre><code>images.forEach(img =&gt; {
      formData.append("productPhotos", img)
  })
  </code></pre>