Created
September 8, 2014 13:19
-
-
Save SpencerCooley/a2dc15fa8024c8fcc1d3 to your computer and use it in GitHub Desktop.
This file contains 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 renderImage(file){ | |
var reader = new FileReader(); | |
reader.onload = function(event){ | |
the_url = event.target.result | |
$('#some_container_div').html("<img src='"+the_url+"' />") | |
} | |
//when the file is read it triggers the onload event above. | |
reader.readAsDataURL(file); | |
} | |
$( "#the-file-input" ).change(function() { | |
console.log(this.files) | |
//grab the first image in the FileList object and pass it to the function | |
renderImage(this.files[0]) | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment