Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

image preview before upload 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 :: react read multiple files with filereader 
Javascript :: timepicker in jquery 
Javascript :: javascript object to array 
Javascript :: convert date and time into epoch javascript 
Javascript :: get src values of set of images inside div with pure JavaScript 
Javascript :: jest to include text 
Javascript :: toarray javascript 
Javascript :: object values 
Javascript :: vuejs cant add script in template 
Javascript :: javascript sort array of object by property 
Javascript :: node js server 
Javascript :: get element of an array inside another array 
Javascript :: Find the maximum number in a jagged array of numbers 
Javascript :: es6 method definition syntax 
Javascript :: preloader js code 
Javascript :: finddomnode is deprecated in strictmode 
Javascript :: remove hostname from url javascript 
Javascript :: remove an element from array 
Javascript :: hover material ui styles 
Javascript :: sort an array of objects in javascript 
Javascript :: change the way Date.now().toString() is logged 
Javascript :: string to date js 
Javascript :: oneerror javascript image 
Javascript :: node sass version react 
Javascript :: poll in javascript 
Javascript :: array of images javascript 
Javascript :: node js event emitter 
Javascript :: first letter uppercase js 
Javascript :: how to get the inner width of a parent div for canvas 
Javascript :: hexstring to rgb array js 
ADD CONTENT
Topic
Content
Source link
Name
6+4 =