我想获取为输入文件选择的文件数。在 HTML 中,我有:
<input id="photoFile" type="file" name="pictures" multiple="multiple"/>
我使用 JQuery,我有:
$('#photoFile').get(0).files.length;
但我发现这不是 Internet Explorer 的解决方案。它适用于 Chrome、Firefox、Safari 和 Opera。如何使其在 IE 8+ 中也能正常工作?
我想获取为输入文件选择的文件数。在 HTML 中,我有:
<input id="photoFile" type="file" name="pictures" multiple="multiple"/>
我使用 JQuery,我有:
$('#photoFile').get(0).files.length;
但我发现这不是 Internet Explorer 的解决方案。它适用于 Chrome、Firefox、Safari 和 Opera。如何使其在 IE 8+ 中也能正常工作?
even IE9 does not support HTML5 File API and therefore it returns undefined value for files property.
由于IE9 不支持File API ,你可以在 Github 上试试这个Polyfill 。
它是File API,IE 8 和 IE 9 不支持。