jQuery
$("form").on("change", "input[type='file']", function() {
if ($(this).val()) {
read_image(this);
}
});
// render image files
function read_image(input) {
if (input.files && input.files[0]) {
var reader = new FileReader();
reader.onload = function (e) {
$(input).parent().find('img').attr('src', e.target.result);
}
reader.readAsDataURL(input.files[0]);
}
}