Suggest a feature
×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: Javascript
Posted by: Ebraheem Bdarni
Added: Jul 19, 2020 12:11 PM
Modified: Jul 20, 2020 9:03 PM
Views: 99
  1.         createImage(file) {
  2.            var reader = new FileReader();
  3.             var vm = this;
  4.                 reader.onload = (e) => {
  5.                    vm.image = e.target.result; // base64
  6.                     /* like:
  7.                     "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAABAAAAAH0CAMAAACU+K8ZAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAADNQTFRFR1xphJObwsnNGDRE8PHzZXeCo6600dbaN09dKEFQ4OTmVmp2dYWPk6CosrvB////CSY3ir2TgAAAKDZJREFUeNrsnde2ozoWAEkSGc7/f223M0EREwSuepk1fX1skLRLWwER/QHAzxJRBAAIAAAQAAAgAABAAACAAAAAAQAAAgAABAAACAAAEAAAIAAAQAAAgAAAAAEAAAIAAAQAAAgAABAAACAAAEAAAIAAAAABAAACAAAEAAAIAAAQAAAgAABAAACAAAAAAQAAAgAABAAACAAAEAAAIAAAQAAACAAAEAAAIAAAQAAAgAAAAAEAAAIAAAQAAAgAABAAACAAAEAAAIAAAAABAAACAAAEAAAIAAAQAAAgAABAAACAAAAAAQAAAgAABAAACAAAEAAAIAAAQAAAgAAAAAEAAAIAAAQAAAgAABAAACAAAEAAAPDDAijU/5yWAV9ciNdUXPFXL1VxCEBZU5n632UIxREl4RVYWin/uYk3/dU29qq9o5ExAjhL/PfqBtdHIVxceAJIc2WBiX7TJq/5es3FHB//PQI4B2nVa9pzAAL4L6ckwPjv1eUVbxr/yq/XXMzhxD0COEn8/29BmvZ8vAD+x39wAtAU2K284k3jX/n1SR+kADYuDQSwbnPWtOfDBXCL/9AEoCmwe3nFmwaU6utlH6QANi4NBLBeiN2bs6Y9Hy2Ae/wHJoBUXWCP8oo3Daj516eyD1IAbY8AThL/9xDTteeDBRA9Li4oAZS5ssCaftMmH6u/P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acHyWAe8eyRAByHEvlDgJ4v0d88QCgsVhLhiqAl/oylgEvIoAi60MQwCOxXPIT5TiW0u0F8B6+58t/rDILoAxUAO/UpxcI4BICeNXowUOA50TeojN2452HAJ/puy9kI4xDgGEKEJIACrf3RCGA08W/eTC7uQDeE/lLpvDGR2m3WwvgE/9fvRNglAJIQ14TkACKzM20COB08d/nRwrgs5C3aFA9SgEqt19Mlgqg6V2SYDv18KIVuYQMTwCj+Dc1BwRwuvg3T54tEUCal/7xv2wIP04BIqdflAsFIFd7e1hiHgNEwQmgcF5vQQDni39j6rxAALbdopr4XxZWrTmdVv1is0wAn/jvvi39UQqQ68cIoQignsS/oT0ggPPFv3FGy18A96Au/ePfMYM3dk2lyy9GiwTwif/8y9WGyW0rrqcJSwCinx... (13958 total length)"
  8.                      */
  9.                 };
  10.              reader.readAsDataURL(file);
  11.        }