IE8-输入(类型=“文件”)获取文件

问题描述 投票:12回答:2

我在Internet Explorer中输入(type =“ file”)有问题(我仅在8中进行了测试。

HTML

<input id="drop-file-files" class="drop-file-waiting" type="file">

JS(http://code.jquery.com/jquery-latest.min.js)

$('#drop-file-files').change(function(e){
    $.each(e.target.files, function(index, file){
        alert(file);
    });
});

它在Firefox,Chrome和Safari中可以完美地返回目标文件,但是IE返回错误,因为e.target中的“文件”未定义。有人知道如何使用JavaScript获得此“文件”吗?

编辑:文档MSDN input type=file-仅在IE10 files property

javascript jquery html internet-explorer
2个回答
14
投票

Internet Explorer 8不支持多个文件。这是already discussed here。您至少可以通过e.target.value获取文件名。


0
投票

在IE8-9中使用值代替文件,会更好

© www.soinside.com 2019 - 2024. All rights reserved.