Show image in html after browser using javascript

Hi I want to display uploaded image in html using javascript. How i can to it.
Ankur Rajput
Asked 20-11-2024
219

Answer (1)
Here is the code. <body>   <input type='file' onchange="showImg(this);" />     <img id="blah" src="#" alt="your image" /> </body> <script> function showImg(input) {         if (input.files && input.files[0]) {             var reader = new FileReader();             reader.onload = function (e) {                 $('#blah')                     .attr('src', e.target.result)                     .width(150)                     .height(200);             };             reader.readAsDataURL(input.files[0]);         }     } </script>
Harsh Aggrawal
Asked 06-07-2018
45 Likes
Comments
Write comment

Submit your answer