通过Ajax Php更新多个文件时出现错误代码4

我正在尝试通过Php和ajax上传多个文件,并且这样做时我收到错误代码4。

我的表单如下:

<script>
$(document).ready(function () {
    $("form#postForm").submit(function (e) {
        e.preventDefault();
        var $form = $(this);
        var formData = new FormData($form[0]); // note [0] here
        $.ajax({
            url: "postHandler",type: 'POST',data: formData,success: function (response) {
                response = JSON.parse(response);
                alert(response.message);
                if (response.success) {
                    window.location.reload();
                }
            },error: function () {
                alert("error");
            },cache: false,contentType: false,processData: false
        });
    });
});

<form id="postForm" enctype="multipart/form-data">
    <input id="file-upload" name="images[]" type="file"/>

    <input id="file-upload" name="images[]" type="file"/>

    <input id="file-upload" type="file" name="file[]"/>

    <input id="file-upload" name="file[]" type="file"/>

    <input id="file-upload" name="file[]" type="file"/>

    <input id="file-upload" name="file[]" type="file"/>

    <input id="file-upload" name="video" type="file"/>
    <input type="submit" class="post-button" name="submit" value="send"/>
</form>

我的php检查是这样的:

$file_field = "images";
    $filenameArr = [];
    if (!empty(array_filter($_FILES[$file_field]['name']))) {
        foreach ($_FILES[$file_field]['name'] as $key => $val) {
            if ($_FILES[$file_field]["error"][$key] !== UPLOAD_ERR_OK) {
                debugToConsole($_FILES[$file_field]["error"][$key]);
                throw new Exception('There was an error');

            }
        }
    }

我得到的错误是4,我不明白为什么,请帮助

sunlei890325sunlei 回答:通过Ajax Php更新多个文件时出现错误代码4

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3137173.html

大家都在问