Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

how to get the image from file input jquery

HTML:

<form id="form1" runat="server">
   <input type='file' id="imgInp" />
   <img id="blah" src="#" alt="your image" />
</form>
jQuery

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

        reader.onload = function (e) {
            $('#blah').attr('src', e.target.result);
        }

        reader.readAsDataURL(input.files[0]);
    }
}

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

PREVIOUS NEXT
Code Example
Javascript :: firebase database TIMESTAMP 
Javascript :: math min js 
Javascript :: react Dark/Light mode 
Javascript :: Compiled with problems:X ERROR [eslint] Plugin "react" was conflicted between 
Javascript :: how to use script tag in javascript 
Javascript :: Bootstrap 5 data attributes different from Bootstrap 4 
Javascript :: make react navigation to always re render 
Javascript :: how to write dummy for loop in jsx 
Javascript :: for loop increment by more than one 
Javascript :: django ajax json data become string 
Javascript :: express docs 
Javascript :: how to square number in javascript 
Javascript :: hreroku 
Javascript :: how to fetch devto api 
Javascript :: html select structure 
Javascript :: configuring styled component to support ssr and hydration 
Javascript :: how to convert html string to jsx element 
Javascript :: jquery keypress div color change 
Javascript :: if this then this, else that 
Javascript :: visual studio code shortcut to find file 
Javascript :: sanitize html before storing to db in js 
Javascript :: react-icons/vsc 
Javascript :: angularjs Indicators and Paginator styling for PrimeNG Carousel 
Javascript :: AngularJS SPA edit button function 
Javascript :: Chrome DevTools - why does variable display in Watch but not under Scope 
Javascript :: How do I change this React Navigation v5 code to v6 
Javascript :: Render JOSN in frontend 
Javascript :: socket.io authentication 
Javascript :: FlatList load top 
Javascript :: select random quotes from array called anecdotes 
ADD CONTENT
Topic
Content
Source link
Name
4+6 =