IE8 - 输入(type ="file")获取文件

Thy*_*tas 12 html javascript jquery internet-explorer

我在Internet Explorer中输入(type ="file")有问题(我仅在8中测试过).

HTML

<input id="drop-file-files" class="drop-file-waiting" type="file">
Run Code Online (Sandbox Code Playgroud)

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

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

它在Firefox,Chrome和Safari返回目标文件中工作得很完美,但IE返回错误,因为e.target中的"files"未定义.有人知道如何使用JavaScript获取此"文件"?

已编辑:文档MSDN输入类型=文件 - 仅在IE10 文件属性中

Mat*_*ias 14

Internet Explorer 8不支持多个文件.这已经在这里讨论过了.您至少可以通过获取文件名e.target.value.