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:

ValueStateDescription
0EMPTYReader has been created. None of the read methods called yet.
1LOADINGA read method has been called.
2DONEThe operation is complete.
EMPTY
The FileReader has been created, but no readAs method was called yet.
LOADING
A readAs method was invoked. A File or Blob is being read, and no error has occurred yet.
DONE
The read operation is complete. This could mean that: the entire File or Blob has been read into memory, a file read error occurred, or abort() 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

SpecificationStatusComment
File API
The definition of 'readyState' in that specification.
Working DraftInitial definition

Browser compatibility

BCD tables only load in the browser

See also

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:80 次

字数:3226

最后编辑:8年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文