【问题标题】:Get the list of files currently attached to the <input> element获取当前附加到 <input> 元素的文件列表
【发布时间】:2012-03-22 16:29:29
【问题描述】:

我正在围绕 jQuery File Upload 插件包装一些 jQuery 功能。它使用&lt;input type="file" name="files[]" multiple="multiple"&gt; 元素在上传之前“连接”选定的文件。当提交输入所在的表单时,文件在服务器上进行解析。

为了调试我的 UI,我需要查看当前“附加”到输入的文件列表。是否可以使用 Firebug 或 Chrome 调试器?

【问题讨论】:

  • 也许this 可以帮忙?

标签: jquery html google-chrome input firebug


【解决方案1】:

是的,您可以只使用控制台和 jquery:

$("#idofinput")[0].files

然后将其视为文件数组:)

【讨论】:

  • @SarathSaleem 你似乎是对的。这是一个展示这个的 jsfiddle(不是我的)...jsfiddle.net/eq3Qv/176
  • 这里有一个 SO 提出了这个问题,但没有完全解决:stackoverflow.com/questions/5000950/ie-input-file-problem
  • 最后,这是另一个 SO 列出了一些替代方案(主要是你必须使用 ActiveX)...难怪 IE 很烂...stackoverflow.com/questions/13512009/…
  • 更正:$("#idofinput")[0].files 'files' 是元素的属性,而不是 jQuery 对象。
  • 有人可以帮帮我吗?我只能使用它获取一个文件,但我选择了多个文件。快把我逼疯了!
【解决方案2】:

这是您可以在控制台中签入的方式:

$("#idofinput").get(0).files

【讨论】:

  • 你摇滚男人(Y)。 get() 是我一直在寻找的 :) 非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-23
  • 1970-01-01
相关资源
最近更新 更多