JSFiddle - React, Tailwind, and code Playground

HTML

<input onchange=file_changed() type=file id=input>
<br>
<img id=img src=file_you_choose>

JavaScript

function file_changed(){
	var selectedFile = document.getElementById('input').files[0];
  var img = document.getElementById('img')
  
  var reader = new FileReader();
  reader.onload = function(){
  img.src = this.result}
  reader.readAsDataURL(selectedFile);
 }