Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Base64 image to multipart/form-data
const base64 = 'data:image/png;base65,....' // Place your base64 url here.
.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 →
const API_URL = ''
fetch(API_URL, {method: 'POST', body: fd)
.then(res => res.json())
.then(res => console.log(res))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.