FileReader.readyState - Web APIs 编辑
The FileReader
readyState
property provides the current state of the reading operation a FileReader
is in. A FileReader
exists in one of the following states:
Value | State | Description |
---|---|---|
0 | EMPTY | Reader has been created. None of the read methods called yet. |
1 | LOADING | A read method has been called. |
2 | DONE | The operation is complete. |
EMPTY
- The
FileReader
has been created, but no readAs method was called yet. LOADING
- A readAs method was invoked. A
File
orBlob
is being read, and no error has occurred yet. DONE
- The read operation is complete. This could mean that: the entire
File
orBlob
has been read into memory, a file read error occurred, orabort()
was called and the read was cancelled.
Example
var reader = new FileReader();
console.log('EMPTY', reader.readyState); // readyState will be 0
reader.readAsText(blob);
console.log('LOADING', reader.readyState); // readyState will be 1
reader.onloadend = function () {
console.log('DONE', reader.readyState); // readyState will be 2
};
Value
A number which is one of the three possible state constants define for the FileReader
API.
Specifications
Specification | Status | Comment |
---|---|---|
File API The definition of 'readyState' in that specification. | Working Draft | Initial definition |
Browser compatibility
BCD tables only load in the browser
See also
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论