Created
March 17, 2015 12:41
-
-
Save JGaudette/68abc9e9a397ce26b31d to your computer and use it in GitHub Desktop.
JS Bin // source http://jsbin.com/ayazin/2
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
<!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> |
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
#base{ | |
padding:10px; | |
background:#eee; | |
} |
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
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