Skip to content

Instantly share code, notes, and snippets.

@christophergorexyz
Created March 24, 2015 21:09
Show Gist options
  • Select an option

  • Save christophergorexyz/b9a50d6ba967d62733c5 to your computer and use it in GitHub Desktop.

Select an option

Save christophergorexyz/b9a50d6ba967d62733c5 to your computer and use it in GitHub Desktop.
read file as base64
<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