JSFiddle - React, Tailwind, and code Playground

by t2t2

HTML

<input id="input" type="file" />
<div id="result">
  Result: ...
</div>

JavaScript

document.getElementById('input').addEventListener('input', function(event) {
	if (event.target.files.length > 0) {
  	document.getElementById('result').innerText = 'Result: ' + event.target.files[0].type
  } else {
		document.getElementById('result').innerText = 'Result: no file'
  }
})