Created
August 15, 2014 09:37
-
-
Save itzaks/dc273ce2e50b1e9dfe55 to your computer and use it in GitHub Desktop.
Html input(type=file) image to base64
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module.exports = (file, cb) -> | |
| valid = (/image\/(gif|jpg|jpeg|tiff|png)$/i).test file.type | |
| return false if not valid | |
| reader = new FileReader() | |
| reader.onload = (e) -> | |
| cb(e.target.result) | |
| reader.readAsDataURL(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment