1<input type="file" accept="image/*" onchange="loadFile(event)">
2<img id="output"/>
3<script>
4 var loadFile = function(event) {
5 var output = document.getElementById('output');
6 output.src = URL.createObjectURL(event.target.files[0]);
7 output.onload = function() {
8 URL.revokeObjectURL(output.src) // free memory
9 }
10 };
11</script>
1function display(input) {
2 if (input.files && input.files[0]) {
3 var reader = new FileReader();
4 reader.onload = function(event) {
5 $('#myid').attr('src', event.target.result);
6 }
7 reader.readAsDataURL(input.files[0]);
8 }
9}
10
11$("#demo").change(function() {
12 display(this);
13});