This article is a mirror article of machine translation, please click here to jump to the original article.

View: 12008|Reply: 1

[HTML/HTML5] HTML5 learning FileReader interface

[Copy link]
Posted on 9/19/2016 10:45:24 AM | | |
It is used to read files into memory and read data from files. The FileReader interface provides an asynchronous API that allows asynchronous access to the file system in the browser's main thread to read data in the file. So far, only FF3.6+ and Chrome 6.0+ have implemented the FileReader interface.

1. The method of FileReader interface
The FileReader interface has 4 methods, 3 of which are used to read files and one to interrupt reading. Regardless of whether the read succeeds or fails, the method does not return a read result, which is stored in the result property.


FileReader interface method name parameter description
readAsBinaryStringfilereads the file as binary encoding
readAsTextfile, [encoding] reads the file as text
readAsDataURLfile reads the file as a DataURL
abort(none) terminal read operation

2. FileReader interface events

The FileReader interface includes a complete event model that captures the state when a file is being read.

FileReader interface
Onabort interrupted
onerror
onloadstart
onprogressis reading
onload successfully read
onloadendread completes, regardless of success or failure

3. Use of FileReader interface








Previous:C# Parameterized Parameters uses sp_executesql to execute sql statements
Next:Image preview is not allowed to load local resource
 Landlord| Posted on 9/19/2016 10:55:41 AM |
https://developer.mozilla.org/zh-CN/docs/Web/API/FileReader  具体介绍
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com