我正在使用 jQuery 表单上传文件并将它们保存到数据库中,我的代码在 chrome 和 mozilla 中运行良好,但在 Internet Explorer 中无法开始上传;我是 grails 框架,我的代码如下:
<g:form controller="uploadImage" action="uploadImage" enctype="multipart/form-data" name="imageUploaderForm" id="imageUploaderForm">
<input type="file" name="image" id="image" onchange="submitImageUploaderForm()" />
<g:hiddenField name="imageType" value=""/>
</g:form>
$("#imageUploaderForm").ajaxForm({
uploadProgress: function(event, position, total, percentComplete) {
$("#progressbar").progressbar({
value : percentComplete
});
$(".progress-label").html(percentComplete+" %");
},
complete: function(response){
//something
}
});
function submitImageUploaderForm(){
//This method gets called !
$("#imageUploaderForm").submit();
}
在控制器中我有以下内容
def uploadImage = {
def response = [result:false,message:"Image could not be uploaded.",uploadInstanceId:0]
def uploadImage = new UploadImage(params)
if(uploadImage.save()) response = [result:true,message: "Image uploaded sucessfully.",uploadInstanceId:uploadImage.id]
render response as JSON
}
当我尝试上传文件时,页面中没有任何反应,但过了一段时间后出现以下异常:
Message: Could not parse multipart servlet request; nested exception is org.apache.commons.fileupload.FileUploadException: Read timed out