Skip to content

Instantly share code, notes, and snippets.

@hadrysmateusz
Created January 3, 2020 01:39
Show Gist options
  • Save hadrysmateusz/5d0eabb4510db2404589c8af9e232661 to your computer and use it in GitHub Desktop.
Save hadrysmateusz/5d0eabb4510db2404589c8af9e232661 to your computer and use it in GitHub Desktop.
Markdium-Files in Client-Side JS: Ultimate Guide to Using Files in Web Applications
// assuming that processImage and processText are functions
if (file.type.startsWith('image/')) {
reader.onload = processImage
reader.readAsDataURL(file)
} else if (file.type.startsWith('text/')) {
reader.onload = processText
reader.readAsText(file)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment