HTML5 FileReader interface learning notes, html5filereader
1. Overview of FileReader
FileReaderObjects allow Web applications to asynchronously read the content of files (or raw data buffers) stored on users' computers.FileOrBlobObject specifies the file or data to be read.
The File object can be<Input>Element returned after selecting a fileFileListObject, which can also be generated by the drag-and-drop operationDataTransferObject can also be fromHTMLCanvasElementRun onReturns the result after the mozGetAsFile () method is used..
2. FileReader Interface Method
| Method Name |
Parameters |
Description |
| ReadAsBinaryString |
File |
Read the file as a binary code |
| ReadAsText |
File, [encoding] |
Read a file as text |
| ReadAsDataURL |
File |
Read the file as DataURL |
| ReadAsArrayBuffer |
File |
Read the fileArrayBuffer object |
| Abort |
(None) |
Interrupted read Operations |
3. FileReader interface event
| Event |
Description |
| Onabort |
Triggered when Data Reading is interrupted |
| Onerror |
Triggered when a data read error occurs. |
| Onloadstart |
Triggered when Data Reading starts. |
| Onprogress |
Reading data |
| Onload |
Triggered when Data Reading is completed successfully. |
| Onloadend |
Triggered when Data Reading is complete, no matter whether the operation fails |
4. Use instances
<! DOCTYPE html>
For more information, see MDN FileReader.