テキストファイル全体を一挙に読み込む
var reader=new FileReader();
reader.readAsText(result);
CSVファイルを一行ずつ読み込む
reader.result.split('\n')
JSON形式を解読する
JSON.parse(reader.result)
画像をロードする
//imageタグのsrc属性に画像ファイルの中身を当てはめる
<imc id="i">
i.src = reader.result;
ローカルファイルにダウンロードする
<a id="btn" download="sample.txt">ダウンロード </a>
const btn = document.getElementById('btn');
btn.addEventListener('click', function() {
const blob = new Blob(['こんにちは'], { "type" : "text/plain" });
btn.href = window.URL.createObjectURL(blob);
})
[参考サイト:https://sejuku.net/ blog/32532]