Skip to content

Instantly share code, notes, and snippets.

View rnidea2code's full-sized avatar

Renish Radadiya rnidea2code

  • idea2code
  • india
View GitHub Profile
@AshikNesin
AshikNesin / base64-form-data.js
Last active September 5, 2024 05:26
Base64 image to multipart/form-data
const base64 = 'data:image/png;base64,....' // Place your base64 url here.
fetch(base64)
.then(res => res.blob())
.then(blob => {
const fd = new FormData();
const file = new File([blob], "filename.jpeg");
fd.append('image', file)
// Let's upload the file
// Don't set contentType manually → https://github.com/github/fetch/issues/505#issuecomment-293064470