gpt4 book ai didi

javascript - 无法在 IE8 中使用 JQuery 上传文件

转载 作者:行者123 更新时间:2023-12-03 11:43:35 26 4
gpt4 key购买 nike

现在,这段代码在 Firefox 中运行良好,但是当我尝试在 IE8 上执行它时,我从浏览器中收到以下错误(恰好在选择文件后)。我完全不知道如何解决它。

IE8错误:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR
3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E) Timestamp: Thu, 2 Oct 2014 06:53:20 UTC


Message: 'length' is null or not an object Line: 2 Char: 2815 Code: 0 URI: http://localhost:8090/JQueryStrutsFileUploadTest/js/jquery-1.11.1.min.js

HTML 行:

<form action="/fileUploadAction.do" id="uploadform" method="POST">
<input id="fileupload" type="file" name="files[]" style="display: none;" multiple />
<input type="button" value="Upload" onclick="document.getElementById('fileupload').click();" />
</form>
<h5 style="text-align:center"><i style="color:#ccc"><small>Max File Size: 2 Mb - Display last 20 files</small></i></h5>

<table id="uploaded-files" class="table" border="1" cellspacing="1">
<tr>
<th>File Name</th>
<th>File Size</th>
<th>File Type</th>
<th>Cancel Action</th>
</tr>
</table>
<table>
<tr>
<td colspan="2"><input type="submit" id="btnSubmit" value="Upload All" /></td>
</tr>
</table>

JQuery 行:

<script src="jquery-1.11.1.min.js"></script>
<script type="text/javascript">

var parent_files = []

$('#fileupload').change(function() {
var user_files = this.files;
$.each(user_files, function( index, file ) {
$("#uploaded-files").append(
$('<tr/>')
.append($('<td/>').text(file.name))
.append($('<td/>').text(file.size))
.append($('<td/>').text(file.type))
.append($('<td/>').html("<a href='#' onclick='javascript:removeFiles(\""+ file.name +"\")'> Cancel </a>"))
)//end $("#uploaded-files").append()

parent_files.push(file);
console.log(parent_files);
});
});
</script>

最佳答案

IE8不支持多个文件:(

关于javascript - 无法在 IE8 中使用 JQuery 上传文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26155870/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com