Skip to content

Instantly share code, notes, and snippets.

@asith-w
Created February 25, 2015 06:13
Show Gist options
  • Save asith-w/50c634e5844f395b5582 to your computer and use it in GitHub Desktop.
Save asith-w/50c634e5844f395b5582 to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/bevowe
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<input id="attach" type="file" /><span id="maxSize">(less than 1MB)</span>
<script id="jsbin-javascript">
$('#attach').change(addAttachment);
function addAttachment() {
readURL(this);
}
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
console.log( e.target.result)
}
reader.readAsDataURL(input.files[0]);
}
}
</script>
<script id="jsbin-source-html" type="text/html"><!DOCTYPE html>
<html>
<head>
<script src="//code.jquery.com/jquery-2.1.1.min.js"><\/script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<input id="attach" type="file" /><span id="maxSize">(less than 1MB)</span>
</body>
</html></script>
<script id="jsbin-source-javascript" type="text/javascript">
$('#attach').change(addAttachment);
function addAttachment() {
readURL(this);
}
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
console.log( e.target.result)
}
reader.readAsDataURL(input.files[0]);
}
}
</script></body>
</html>
$('#attach').change(addAttachment);
function addAttachment() {
readURL(this);
}
function readURL(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
console.log( e.target.result)
}
reader.readAsDataURL(input.files[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment