Source Code:
(back to article)
Submit
Result:
Report an issue
<input type="file" id="textInput" /> <div id="textOutput">Upload a text file please</div> <script> document.getElementById('textInput').addEventListener('change', function(event) { const file = event.target.files[0]; const reader = new FileReader(); reader.onload = function(e) { document.getElementById('textOutput').innerHTML = e.target.result; }; reader.readAsText(file); }); </script>