这是我的HTML
<form id="theuploadform">
<input id="upload" type="file" name="upload" style="display:none;" />
<input type="submit" name="" id="fileuploadcsv" value="Upload">
</form>
这是我的javascript文件
$("#fileuploadcsv").click(function () {
// e.preventDefault();
// for uploading click
var uploadValue = '';
uploadValue = $("#upload").val();
if(!uploadValue){
$('#selectfileerror').removeClass("hide");
return false;
}else{
$('#selectfileerror').addClass("hide");
}
// Find extension of selected file.
var ext = '';
ext = uploadValue.split('.').pop();
ext = ext.toLowerCase();
if(ext != 'csv'){
$('#fileformaterror').removeClass("hide");
return false;
}else{
$('#fileformaterror').addClass("hide");
}
var iframe = $('<iframe name="postiframe" id="postiframe" style="display: none"></iframe>');
$("#frameappend").append(iframe);
var form = $('#theuploadform');
form.attr("action", "/elearning/import_courses");
form.attr("method", "post");
form.attr("file", $('#upload').val());
// form.attr("encoding", "multipart/form-data");
form.attr("enctype", "multipart/form-data");
form.attr("target", "postiframe");
form.submit();
$("#postiframe").load(function () {
alert("postframe load");
iframeContents = this.contentWindow.document.body.innerHTML;
alert(iframeContents);
});
return false;
});
});
这在其他浏览器中工作正常。 IE中没有显示错误并且警告为空。
如果有人知道这一点,请帮助我。