Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <head> <title>Title of the Document</title> </head> <body> <input onchange="readFile(this)" type="file"> <script> function readFile(input) { let file = input.files[0]; let fileReader = new FileReader(); fileReader.readAsText(file); fileReader.onload = function() { alert(fileReader.result); }; fileReader.onerror = function() { alert(fileReader.error); }; } </script> </body> </html>