Upload Image and Display On Screen

by DiegoTc

HTML

<input type='file' />
<img id="myImg" src="#" alt="your image" />












<!-- Post Info -->
<div style='position:fixed;bottom:0;left:0;    
            background:lightgray;width:100%;'>
    About this SO Question <a href='http://stackoverflow.com/q/19866677/1366033'>A button for Open Dialog Box using HTML and JQuery</a><br/>
<div>

JavaScript

$(function () {
    $(":file").change(function () {
        if (this.files && this.files[0]) {
            var reader = new FileReader();
            reader.onload = imageIsLoaded;
            reader.readAsDataURL(this.files[0]);
        }
    });
});

function imageIsLoaded(e) {
    $('#myImg').attr('src', e.target.result);
};