lib/script.js
function loadHandler (event) {
    const target = event.target;

    // change the link to the new file
    link.setAttribute('href', target.result);

    // make sure checkbox is no longer checked
    checkbox.checked = false;

    // make link not hidden
    link.style.display = '';

    // make delete checkbox not hidden
    deleter.style.display = '';

    // image uploaded
    if (file.type.match('image.*')) {
      // create image
      const image = new Image();
      image.title = file.name;
      image.src = target.result;

      // replace file--link contents
      link = clear(link);
      link.appendChild(image);
    }
    else {
      // non-image file
      link.textContent = file.name;
    }
  }
function loadHandler (event) {
    const target = event.target;

    // change the link to the new file
    link.setAttribute('href', target.result);

    // make sure checkbox is no longer checked
    checkbox.checked = false;

    // make link not hidden
    link.style.display = '';

    // make delete checkbox not hidden
    deleter.style.display = '';

    // image uploaded
    if (file.type.match('image.*')) {
      // create image
      const image = new Image();
      image.title = file.name;
      image.src = target.result;

      // replace file--link contents
      link = clear(link);
      link.appendChild(image);
    }
    else {
      // non-image file
      link.textContent = file.name;
    }
  }
function loadHandler ( event ) { const target = event . target ; // change the link to the new file link . setAttribute ( 'href' , target . result ) ; // make sure checkbox is no longer checked checkbox . checked = false ; // make link not hidden link . style . display = '' ; // make delete checkbox not hidden deleter . style . display = '' ; // image uploaded if ( file . type . match ( 'image.*' ) ) { // create image const image = new Image ( ) ; image . title = file . name ; image . src = target . result ; // replace file--link contents link = clear ( link ) ; link . appendChild ( image ) ; } else { // non-image file link . textContent = file . name ; } }
Load handler for FileReader
@param  {[type]} event - handler executed when the load event is fired
Load handler for FileReader