JSFiddle - React, Tailwind, and code Playground

by Christian Sonne

HTML

<input type="file" accept="image/png, image/jpeg" name="image" id="img">

JavaScript

img.addEventListener("change", function(e) {
	if (this.files.length) {
  	var reader  = new FileReader();
    reader.addEventListener("load", function() {
    	console.log(this.result)
    });
    reader.readAsDataURL(this.files[0])
  }
})