Created
March 24, 2015 21:09
-
-
Save christophergorexyz/b9a50d6ba967d62733c5 to your computer and use it in GitHub Desktop.
read file as 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
| <html> | |
| <head> | |
| <meta http-equiv="content-type" content="text/html; charset=utf-8"> | |
| <title>test</title> | |
| </head> | |
| <body> | |
| <input type="file" capture="camera" accept="image/*" id="cameraInput" name="cameraInput"> | |
| <script type="text/javascript"> | |
| var i = document.getElementById('cameraInput'); | |
| var fileReader = new FileReader(); | |
| i.addEventListener('change', function(e){ | |
| e.preventDefault(); | |
| fileReader.onload = function(e){ | |
| console.log(e.target.result); | |
| var out = new Image(); | |
| out.src = e.target.result | |
| document.body.appendChild(out); | |
| } | |
| fileReader.readAsDataURL(this.files[0]); | |
| }); | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment