Safari 11.1: ajax/XHR form submission fails when input[type=file] is empty

后端 未结 6 551
南笙
南笙 2021-01-30 21:09

UPDATE: As of Webkit build r230963, this issue has been resolved in Webkit.

===========

Since the recent Safari 11.1 update on macOS and iOS, as

6条回答
  •  借酒劲吻你
    2021-01-30 21:31

    I worked on what appears to be the same issue in a Perl-program

    Processing multipart/form-data in Perl invokes Apache-error with Apple-devices, when a form-file-element is empty

    Workaround is removing the form-elements before the formdata is assigned:

    $('#myForm').find("input[type='file']").each(function(){
        if ($(this).get(0).files.length === 0) {$(this).remove();}
    });
    var fData = new FormData($('#myForm')[0]);
    ...
    

提交回复
热议问题