FileReader: FileReader() コンストラクター
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since 2015年7月.
メモ: この機能はウェブワーカー内で利用可能です。
FileReader() コンストラクターは、新しい FileReader を作成します。
FileReader の使用方法の詳細については、ウェブアプリケーションからのファイルの使用を参照してください。
構文
js
new FileReader()
引数
なし。
例
次のコードスニペットは、FileReader オブジェクトを FileReader() コンストラクターで作成し、引き続きそのオブジェクトを使用する方法を示しています。
js
function printFile(file) {
const reader = new FileReader();
reader.onload = (evt) => {
console.log(evt.target.result);
};
reader.readAsText(file);
}
仕様書
| Specification |
|---|
| File API> # filereaderConstrctr> |
ブラウザーの互換性
Loading…