在Firefox中选择HTML5多文件输入目录? [英] Select directory for HTML5 multiple file input in Firefox?
问题描述
在Chrome中,我可以添加 webkitdirectory
属性来启用此功能。根据这个问题和一个答案这个问题你应该可以在firefox中使用 mozdirectory
来做同样的事情,但是我无法使用它。
I (在Chrome中可用):
< input type =fileid = filesname =files []multiple mozdirectory =webkitdirectory =directory =/>
我的Firefox版本是10.0。
有没有什么办法可以让用户在Firefox中选择一个输入目录,而不需要客户端的附加组件(比如Flash)?
Firefox没有任何API来上传目录(这是一个耻辱)...即使在夜间编译,所以我不认为我们会很快看到支持。 IE也没有一个。如果你想利用这个功能,你必须强制用户使用谷歌浏览器(例如,让他们知道上传目录只在Chrome浏览器中可用)。
解决方法将压缩.zip文件中的目录并使用 FileReader
API读取它。请参阅 https://stackoverflow.com/a/7842896/613453
IE Edge现在支持这个功能。
https://msdn.microsoft.com/en-us/library/mt574730(v = vs.85).aspx < a>
I want to allow users to select a local directory on a webpage (and then read all the files in the directory).
In Chrome I can add the webkitdirectory
attribute to enable this functionality. According to a comment in this question and an answer to this question you should be able to do the same in firefox using mozdirectory
but I am unable to get it to work.
I have tried the following in Firefox with no luck (works in Chrome):
<input type="file" id="files" name="files[]" multiple mozdirectory="" webkitdirectory="" directory="" />
My Firefox version is 10.0.
Are there any way for a user to select a directory for input in Firefox without requiring an add-on on the client-side (like Flash)?
Firefox doesn't have any API to upload directories yet (which is a shame)...not even in the nightly builds, so I don't think we will see support on this very soon. IE doesn't have one either. If you want to take advantage of this feature you must force the users to use Google Chrome (e.g. make them aware that upload directory is available only in Chrome).
A workaround would be to compress the directory in a .zip file and read it with the FileReader
API. See https://stackoverflow.com/a/7842896/613453
Update
IE Edge now has support for this.
https://msdn.microsoft.com/en-us/library/mt574730(v=vs.85).aspx
这篇关于在Firefox中选择HTML5多文件输入目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!