Skip to content

Instantly share code, notes, and snippets.

@Axiol
Created November 21, 2012 23:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Axiol/4128607 to your computer and use it in GitHub Desktop.
Save Axiol/4128607 to your computer and use it in GitHub Desktop.
Preview the image from an input file
// Call this function on the onchange event of the input
function prevVisu(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function(e){
$("div#visuForm").html("<img class='img-polaroid' src='" + e.target.result + "' alt='Preview du visuel'>");
};
reader.readAsDataURL(input.files[0]);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment