Skip to content

Instantly share code, notes, and snippets.

@JGaudette
Created March 17, 2015 12:41
Show Gist options
  • Save JGaudette/68abc9e9a397ce26b31d to your computer and use it in GitHub Desktop.
Save JGaudette/68abc9e9a397ce26b31d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/ayazin/2
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<style id="jsbin-css">
#base{
padding:10px;
background:#eee;
}
</style>
</head>
<body>
<input type='file' id="asd" />
<img id="img" src="" />
<div id="base"></div>
<script id="jsbin-javascript">
function readImage(input) {
if ( input.files && input.files[0] ) {
var FR= new FileReader();
FR.onload = function(e) {
$('#img').attr( "src", e.target.result );
$('#base').text( e.target.result );
};
FR.readAsDataURL( input.files[0] );
}
}
$("#asd").change(function(){
readImage( this );
});
</script>
<script id="jsbin-source-css" type="text/css">#base{
padding:10px;
background:#eee;
}</script>
<script id="jsbin-source-javascript" type="text/javascript">function readImage(input) {
if ( input.files && input.files[0] ) {
var FR= new FileReader();
FR.onload = function(e) {
$('#img').attr( "src", e.target.result );
$('#base').text( e.target.result );
};
FR.readAsDataURL( input.files[0] );
}
}
$("#asd").change(function(){
readImage( this );
});</script></body>
</html>
#base{
padding:10px;
background:#eee;
}
function readImage(input) {
if ( input.files && input.files[0] ) {
var FR= new FileReader();
FR.onload = function(e) {
$('#img').attr( "src", e.target.result );
$('#base').text( e.target.result );
};
FR.readAsDataURL( input.files[0] );
}
}
$("#asd").change(function(){
readImage( this );
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment