Javascript Articles - Page 547 of 671

Setting null values with an HTML display as image rather than “choose file” button

Chandu yadav
Updated on 25-Jun-2020 05:31:47

392 Views

Use the JavaScript FileReader to allow users to choose an image.Let us see an example −         Here is the JS −function readURL(input) {    if (input.files && input.files[0]) {       var r = new FileReader();       r.onload = function (ev) {          $('#myid).attr('src', ev.target.result);       }       reader.readAsDataURL(input.files[0]);    } }   

Advertisements