Skip to content

Instantly share code, notes, and snippets.

@atakde
Created October 16, 2022 13:05
Show Gist options
  • Save atakde/637173ebc223beff8a6e0b575788c957 to your computer and use it in GitHub Desktop.
Save atakde/637173ebc223beff8a6e0b575788c957 to your computer and use it in GitHub Desktop.
Convert to base 64
const handleImageUpload = (e: any) => {
const file = e.target.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onloadend = () => {
console.log(reader.result);
// make request to your backend
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment