Open text (.txt) from local file and show content in textarea [ source code & demo ] In this example we are using file system API to open a text file from local files and show content into textarea tag <button id="open"> open File</button> <textarea id="textarea" style="width:100%;height:300px">Free Online HTML editor autocomplete with CSS & JS</textarea> <script> document.getElementById("open").onclick = function() { openFile() } async function openFile() { let fileHandle; [fileHandle] = await window.showOpenFilePicker(); const file = await fileHandle.getFile(); const contents = await file.text(); document.getElementById("textarea").value = contents; } </script> © Manajmnt code Share to : ☷✎ Comments
Comments
Post a Comment
message