Set background image on div.

<input type=”file”  class=”square_thumb_input” onchange=”readURL(this);” >

function readURL(input,id) {

if (input.files && input.files[0]) {
var reader = new FileReader();

      reader.onload = function (e) {
$(‘.square_thumb_input’).css(‘background-image’, ‘url(‘ + e.target.result + ‘)’);
// $(‘#’+id) user class or id of div which have display image.
};
reader.readAsDataURL(input.files[0]);
}
}

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...