Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

preview upload image jquery

// <input type="file" accept="image/*" id="img-input">
// <img id="preview"/>
function readURL(input) {
      if (input.files && input.files[0]) {
          var reader = new FileReader();
          reader.onload = function(e) {
          $('#preview').attr('src', e.target.result);
          }
          reader.readAsDataURL(input.files[0]);
      } else {
          $('#preview').attr('src', '');
      }
    }

  $("#img-input").change(function() {
    readURL(this);
  });
Comment

PREVIOUS NEXT
Code Example
Javascript :: contains() js 
Javascript :: jquery set select value 
Javascript :: socket.io client send data node js server 
Javascript :: react slick 
Javascript :: how set defualt image for dropify 
Javascript :: react bootstrap form select 
Javascript :: electron how to setup preload.js 
Javascript :: angular pipe percentage 
Javascript :: javascript random number up to including 2 
Javascript :: how to use trim in node js 
Javascript :: fabric download 
Javascript :: js toggle 
Javascript :: get element by id jqueryt 
Javascript :: scroll to top 
Javascript :: js array includes 
Javascript :: error metro bundler process exited with code 1 react native 
Javascript :: how to find all elements starting with class jquery 
Javascript :: javascript getcontext 
Javascript :: momentjs format date 
Javascript :: angular list contains property 
Javascript :: window.addeventlistener 
Javascript :: request animation frame 
Javascript :: javascript create array with repeated values 
Javascript :: how to use console.log in vuejs 
Javascript :: how to find last element in array in javascript 
Javascript :: array every javascript 
Javascript :: how to add items in an array in js 
Javascript :: javascript class methods 
Javascript :: getDataSnapshotFirebase 
Javascript :: js code sample 
ADD CONTENT
Topic
Content
Source link
Name
3+3 =