如何拉多个文件html5 jquery [英] how to pull multiple files html5 jquery

查看:135
本文介绍了如何拉多个文件html5 jquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用FileSystem Api(Html5)来拉多个文件并将其作为数组发送到JavaScript。
其实我试图选择多个文件并将它们添加到我的幻灯片中。

任何帮助将不胜感激。

问题
--AJ

解决方案

您需要添加多个属性到您的输入

 < input type =filemultiple /> 

您也可以添加 webkitdirectory 目录和/或 mozdirectory 来指定您想允许用户上传整个文件夹。这些都不是标准的,显然(尽管普通的ol 目录是/可能的)然后在你的JavaScript中,您的输入元素将有一个文件数组,包含所选文件的元信息,可以在FileReader API中使用。例如:

 < input type =filemultiple onchange =doSomethingWithThese(this.files)/> 

(例如,我不建议使用内联JavaScript)

How to pull multiple files using FileSystem Api (Html5) and send to javascript as an array. Actually I'm trying to select multiple files and add them to my slideshow.

Any help would be appreciated.

Regards --A.J

解决方案

You need to add the multiple attribute to your input

 <input type="file" multiple />

You can also add webkitdirectory, directory, and/or mozdirectory to specify you want to allow users to upload entire folders. These are not standard, obviously (although plain ol' directory is/may be)

Then in your JavaScript, your input element will have a files array containing meta info on the selected files, ripe for using in the FileReader API. For example:

 <input type="file" multiple onchange="doSomethingWithThese(this.files)" />     

(I don't recommend the inline JavaScript, just for example)

这篇关于如何拉多个文件html5 jquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆