我在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中
Internet Explorer 8不支持多个文件。这是already discussed here。您至少可以通过e.target.value
获取文件名。
在IE8-9中使用值代替文件,会更好