Javascript examples for DOM HTML Element:Input Text
Reading a text file using FileReader Javascript object for input file field
<html> <head></head> <body> <input type="file" id="openfile"> <br> <pre id="filecontents"></pre> <script type="text/javascript"> document.getElementById("openfile").addEventListener('change', function() { var fr = new FileReader();/*from w ww . j av a 2 s.com*/ fr.onload = function() { document.getElementById("filecontents").textContent = this.result; } fr.readAsText(this.files[0]); }) </script> </body> </html>