<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>File API</title>
<script>
function processFiles()
{
var filelist = document.getElementById('files').files;
for(var i=0; i<filelist.length; i++)
{
writefiles(filelist[i]);
}
}
function writefiles(file)
{
var reader = new FileReader();
reader.onload = function()
{
document.getElementById('output').innerText += reader.result;
}
reader.readAsText(file, "UTF-8");
}
</script>
</head>
<body>
Select a text file:
<input type="file" accept='text/plain' multiple id="files" onchange="processFiles()" />
<pre id="output"></pre>
</body>
</html>