RAZPiblog Soft RAZPiblog Soft

Code Membuat Tools Image Menjadi Base 64

 

Code Membuat Tools Image Menjadi Base 64

Oke guys kali ini saya akan berbagi source code tools untuk convert gambar ke base64

Langsung saja cek dibawah

 <input id="file" type="file">
<div id="list"></div>
  
      <script id="rendered-js">
function handleFileSelect(evt) {
  var f = evt.target.files[0];
  var reader = new FileReader();

  // Closure to generate the handler we need
  // with the correct scope.
  reader.onload = function (theFile) {

    // returning the handler that will be called for reader.onload
    return function (e) {

      // Render thumbnail.
      var span = document.createElement('span');
      span.innerHTML = ['<img class="thumb" src="', e.target.result,
      '" title="', escape(theFile.name), '" width="250"/>'].join('');
      document.getElementById('list').insertBefore(span, null);
    };
  }(f);

  // Read in the image file as a data URL.
  // this triggers reader.onload
  reader.readAsDataURL(f);
}

document.getElementById('file').addEventListener('change', handleFileSelect, false);
    </script>
See Also :