let files = document.querySelector('input[type="file"]').files; const reader = new FileReader(); reader.onload = () => { const lines = reader.result; setText(lines); }; reader.readAsText(files[0]); };