我正在尝试使用ajax上传图片,因此我使用了FormData,但在IE8中无法正常工作。我查看了一些资料,发现不能在IE8中使用FormData,但我找不到其他的解决方案来使它在IE8和其他浏览器上正常工作。请问有人能告诉我该如何解决,以及如何操作吗?
我要提交的表单
<form id="addImgForm" name="addImgForm" method="post" action="#URL(Action('ChiliTest-ImageUpload'))#" enctype="multipart/form-data">
<input id="newImage" type="file" name="newImage">
<input type="hidden" name="MAX_FILE_SIZE" value="12345">
<span id="addImage" class="button-addImage" type="submit"><isTradConstant keyword="l_customizationsChiliEditor_AddImageButtonTitle" template="CustomizationsChiliEditor" init="Ajouter"></span>
</form>
在添加图片表单提交时调用
$.ajax({
url: myUrl,
type: "POST",
data: new FormData($(this).parent()[0]),
contentType : false,
async: false,
processData: false,
cache: false,
success: function(data) {
//do something
}
});
return false;