HTML5 File API - availability and abilities

岁酱吖の 提交于 2019-12-12 16:57:13

问题


I just did some reading on File API and I'm wondering now when almost all major browsers are going to support it or supports it already:

Firefox, since 3.6 Chrome, since 8.0

? Opera, IE ?

Is this supposed to be a successor/alternative of uploaders based on flash, like plupload or sfwupload ? What is the advantage and disadvantage of it in this case ?

Is it able to reliably handle Blobs (byte streams) / files so that when the inputstreams are read by the FileReader, does it have the same consistency as the native file load from filesystem? I mean encoding issues etc.

After a user submits the file, can I freely use it without any restrictions with javascript? For instance save the file into a variable and then later send it via XHR ?

I've read all this in the specifications, but I'd like to hear opinions of somebody who has some experiences with it. I'm about to implement a complicated user interface and with File API there would be way lesser work to do on the server side...

But I'm not sure if I should use it or not because of ? Opera, IE ?


回答1:


I have no idea when/if IE will support this, but they may be forced to by public demand.

According to the spec the Blob (raw data) is one way to read in a file (http://www.w3.org/TR/FileAPI/#dfn-Blob).

Once you have the data you should be able to process it, as shown in this tutorial: https://developer.mozilla.org/en/Using_files_from_web_applications, but you won't be able to write the data back, so you would need to send it to the server.

This will replace Flash uploaders, for example, but until the vast majority of people use new browsers, or you choose to no longer support the older browsers these other solutions will be around.

But, if you want to create a cutting-edge page that allows the user to drag-and-drop onto something other than a <input> tag then some of the HTML5 APIs will be helpful, as shown here: http://robertnyman.com/2010/04/22/using-the-file-api-for-reading-file-information-multiple-file-uploads-another-sister-specification-to-html5/.



来源:https://stackoverflow.com/questions/4799665/html5-file-api-availability-and-abilities

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!