我有以下的HTML代码jQuery的获取IE造成错误9
<label class="fileinput-button" id="fileUpload-label">
<span class="btn btn-add" id="fileUpload-span">Add a file..</span>
<div id="fileinput-outer">
<input type="file" name="files[]" id="fileUpload">
</div>
</label>
然后我使用jQuery获得与输入类型的文件列表=文件
$('#fileUpload').live('change', function() {
$.map($('#fileUpload').get(0).files, function (file) {
$('#fileList')
.append(CreateFileList(file.name, true));
});
});
这伟大工程Chrome和Firefox,但在IE中的错误是
Unable to get value of the property 'length': object is null or undefined
所以我开始麻烦,并有此代码
var arrFiles[];
arrFiles = $('#fileUpload').get(0).files;
if(arrFiles.length === 0) {
alert('empty');
} else {
alert('has value');
}
Chrome和Firefox - 代码,并提醒如预期,但仍IE抛出错误
Unable to get value of the property 'length': object is null or undefined
好像IE可能与jQuery的问题找..
任何人知道如何我可以解决这个错误在IE浏览器有或没有JQuery的?
有你尝试使用'.data('files',files)'而不是'.get(0).files = files'来存储文件?在IE9之前,我有问题将数据绑定到DOM。 –