Follow Us

LightBlog

Breaking

Showing posts with label Asp. Net MVC. Show all posts
Showing posts with label Asp. Net MVC. Show all posts

Saturday, August 1, 2020

August 01, 2020

Select and display image(s) using FileReader using Jquery.

HTML CODE:
<input class="joint" type='file' id="imgInp" />
<img style="width:45px" id="blah" src="#" alt="your image" />

Jquery CODE:

<script type="text/javascript">

$("#imgInp").change(function()
{
    readURL(this);
});

function readURL(input) {

    if (input.filers && input.files[0]) {
        var reader = new FileReader();
           reader.onload = function (e) {
            $('#blah').attr('src', e.target.result);
        }
       reader.readAsDataURL(input.files[0]);
    }
}
</script>

Saturday, July 11, 2020