本文介绍了HTML5文件API - 可用性和功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在File API上做了一些阅读,我现在想知道几乎所有主流浏览器都支持它还是已经支持它了:



Firefox,因为3.6
Chrome,自8.0以来



? Opera,IE?



这应该是基于flash的上传者的继承者/替代者,比如plupload或sfwupload吗?在这种情况下它的优点和缺点是什么?



是否能够可靠地处理Blob(字节流)/文件,以便在FileReader读取输入流时,它与文件系统的本机文件加载具有相同的一致性吗?我的意思是编码问题等。



用户提交文件后,我可以自由使用它而不受javascript的任何限制吗?例如,将文件保存到变量中,然后通过XHR发送?



我已经在规范中阅读了所有这些,但我想听听有经验的人。我即将实现一个复杂的用户界面,使用File API在服务器端做的工作也会少一些......



但我不确定如果因为我应该使用它? Opera,IE?

解决方案

我不知道IE何时会支持这一点,但他们可能会被公众要求强迫。



根据规范, Blob (原始数据)是读取文件的一种方式()。



获得数据后,您应该能够处理它,如本教程所示:,但您将无法将数据写回,因此您需要将其发送到服务器。 / p>

例如,这将取代Flash上​​传器,但在绝大多数人使用新浏览器或您选择不再支持旧版浏览器之前,这些其他解决方案将会出现。



但是,如果你想创建一个允许用户拖放到以外的其他东西的尖端页面。输入> 标签,然后一些HTML5 API会有所帮助,如下所示:。


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.6Chrome, 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 ?

解决方案

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/.

这篇关于HTML5文件API - 可用性和功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 16:06