Javascript 无法使用JQuery在IE8中上载文件
现在,这段代码在Firefox中运行得很好,但是当我尝试在IE8上执行它时,我从浏览器中得到以下错误(恰好在选择文件之后)。我完全不知道如何解决它 IE8错误:Javascript 无法使用JQuery在IE8中上载文件,javascript,jquery,html,internet-explorer-8,Javascript,Jquery,Html,Internet Explorer 8,现在,这段代码在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.307
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
<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>
<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>
HTML行:
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
<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>
<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>
最大文件大小:2 Mb-显示最后20个文件
文件名
文件大小
文件类型
取消操作
JQuery行:
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
<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>
<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>
var parent_files=[]
$('#fileupload').change(function(){
var user_files=this.files;
$.each(用户文件、函数(索引、文件){
$(“#上载的文件”).append(
$('')
.append($('').text(file.name))
.append($('').text(file.size))
.append($('').text(file.type))
.append($(“”).html(“”)
)//end$(“#上载的文件”).append()
父文件。推送(文件);
console.log(父文件);
});
});
IE8不支持多个文件:(Ya,我认为这是问题的根本原因。非常感谢:)我希望我能说得更多,但事实就是这样。