Skip to content

Instantly share code, notes, and snippets.

@sharmaansh21
Created January 22, 2014 08:15
Show Gist options
  • Select an option

  • Save sharmaansh21/8555181 to your computer and use it in GitHub Desktop.

Select an option

Save sharmaansh21/8555181 to your computer and use it in GitHub Desktop.
Image view
$(document).ready(function(){
var preview = $(".upload-preview img");
$(".file").change(function(event){
var input = $(event.currentTarget);
var file = input[0].files[0];
var reader = new FileReader();
reader.onload = function(e){
image_base64 = e.target.result;
preview.attr("src", image_base64);
};
reader.readAsDataURL(file);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment