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 :: preview upload image js 
Javascript :: contains() js 
Javascript :: tolocalestring format dd-mm-yyyy 
Javascript :: nepali date picker 
Javascript :: js count element tags 
Javascript :: js check if two arrays contain same values 
Javascript :: react pass props to child 
Javascript :: get domain name with regex 
Javascript :: how to get common elements from two array in javascript using lodash 
Javascript :: js json data undefined 
Javascript :: regex to find emails 
Javascript :: javascript competitive programming 
Javascript :: require a json as a string 
Javascript :: javascript creeate utc date 
Javascript :: js if dark mode 
Javascript :: js key value array 
Javascript :: how to take screenshot of desktop using electron js 
Javascript :: react native only 1 corner rounded 
Javascript :: format date javascript 
Javascript :: export default method vue 
Javascript :: delete all objects in array of objects with specific attribute 
Javascript :: js get selected option element 
Javascript :: file name in react input 
Javascript :: how to get key from value in javascript 
Javascript :: how to get an array from another script in js 
Javascript :: javascript get focusable elements 
Javascript :: what is JSON TREE 
Javascript :: get current file name javascript 
Javascript :: searching in json array mongodb 
Javascript :: store images in mongoose 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =