Skip to content

Instantly share code, notes, and snippets.

@joeypy
Created December 24, 2022 11:47
Show Gist options
  • Save joeypy/8d5695af8b88311f923e5c1aa7dffac2 to your computer and use it in GitHub Desktop.
Save joeypy/8d5695af8b88311f923e5c1aa7dffac2 to your computer and use it in GitHub Desktop.
Convert to base64 js
const toBase64 = file => new Promise((resolve, reject) => {
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => resolve(reader.result);
reader.onerror = error => reject(error);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment