title: How to manually create multipart/form-data
body: <p>We can use <a href="https://fetch.spec.whatwg.org/#dom-body-formdata" rel="noreferrer"><code>.formData()</code></a> of <a href="https://fetch.spec.whatwg.org/#body" rel="noreferrer"><code>Body</code></a> mixin to return a <code>FormData</code> representation of data at <a href="https://developer.mozilla.org/en-US/docs/Web/API/Body/formData#Browser_compatibility" rel="noreferrer">Chromium (Chrome) 60+ and Firefox 39+</a></p>
  
  <p>Relevant specifications:</p>
  
  <ul>
  <li><a href="https://www.w3.org/Protocols/rfc1341/7_2_Multipart.html" rel="noreferrer">7.2 The Multipart Content-Type</a></li>
  <li><a href="https://www.ietf.org/rfc/rfc2388.txt" rel="noreferrer">Returning Values from Forms:  multipart/form-data</a></li>
  </ul>
  
  <p>Errata </p>
  
  <ul>
  <li><a href="https://github.com/whatwg/fetch/issues/392" rel="noreferrer">Clarification of Body package data algorithm with bytes, FormData and multipart/form-data MIME type #392</a></li>
  <li><a href="https://github.com/whatwg/html/issues/3040" rel="noreferrer">Documenting de-facto handling of multipart/form-data form field file uploads #3040</a></li>
  </ul>
  
  <p>Related</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/47067312/multipart-http-response">Multipart HTTP response</a></li>
  <li><a href="https://stackoverflow.com/q/13870853/">How to upload files in Web Workers when FormData is not defined</a></li>
  </ul>
  
  <p>How to manually create <code>multipart/form-data</code> using JavaScript at client and at server to serve the <code>multipart/form-data</code> as a response? </p>