Image Upload Preview

by Naresh

HTML

<input type="file" accept="image/" onchange="loadImg()">

<div>
  <img id="photo-preview" width="100px" height="100px" />
</div>

JavaScript

function loadImg() {
  $('#photo-preview').attr('src', URL.createObjectURL(event.target.files[0]));
}