Tengo una entrada de archivo como esta en html
<input type='file' id='textin'></input>¿Cómo obtengo el contenido del archivo .txt cargado?
Puede hacerlo a través de FileReader .
function previewFile() { const content = document.querySelector('.content'); const [file] = document.querySelector('input[type=file]').files; const reader = new FileReader(); reader.addEventListener("load", () => { // this will then display a text file content.innerText = reader.result; }, false); if (file) { reader.readAsText(file); } } <input type="file" onchange="previewFile()" id="textin"><br> <p class="content"></p>