本文介绍了IE8上的FormData ajax上传 - >替代方案及其运作方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用ajax上传图片,因此我使用的是FormData,但它不适用于IE8。我看过它并且不可能将FormData与IE8一起使用,但我发现没有什么我能够使用它来使其在IE8和其他浏览器上运行。有人可以告诉我该怎么做,以及怎么做?

I'm tyring to upload a picture with ajax, so I'm using FormData, but it's not working with IE8. I've looked about it and it's not possible to use FormData with IE8, but I've found nothing I've been able to use instead in order to make it work on IE8 and other browser. Could someone tell me what to do please, and how to do it ?

我试图提交的表格

<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>

调用addImgForm提交

Called on addImgForm submit

$.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;


推荐答案

理想情况下,当我遇到此问题时,我检查了FormData在浏览器中,如果返回undefined,那么我通过iframe进行表单提交。

Ideally when i faced this issue, i checked for FormData in browser and if that returns undefined, then i went for form submission via an iframe.

这篇关于IE8上的FormData ajax上传 - &gt;替代方案及其运作方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-29 12:36