FormData ajax upload on IE8 -> alternatives and how it works

13,949

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.

Share:
13,949
NeS
Author by

NeS

Updated on September 04, 2022

Comments

  • NeS
    NeS over 1 year

    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 ?

    The form I'm trying to submit

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

    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;