duanhuoyao7011 2018-02-07 14:33
浏览 64
已采纳

多文件上传不会向服务器发送任何数据

I want to upload multiple file upload. I have this on client side :

        $(document).on( "click", ".save-button", function () {

            var data = new FormData();
            data.append('title', $(this).parent().parent().find("#title_place").val());

            $.each($(this).parent().parent().find("input[type='file']")[0].files, function(i, file) {
                data.append('file', file);
            });

            $.ajax({type: "POST",
                url: 'save_view.php',
                data: data,
                success : viewSaveCallBack,
                cache: false,
                contentType: false,
                processData: false,
            });
        });

I checked all the data in the debuger, and it is working properly. To see this I displayed the value of

 $(this).parent().parent().find("#title_place").val()

And

$(this).parent().parent().find("input[type='file']")[0].files

Then, when I try to var_dump $_FILES or $_POST on server side, it's empty. Same thing with a debugger. enter image description here enter image description here

I tried also with

                data.append('files[]', file);

When I try to upload a single file (in another input, not exactly the same code), that is working fine.

The html of the input is this one :

        <input type=\"file\" multiple directory webkitdirectory allowdirs class=\"form-control input\" id=\"marzipano\">

And it is added dynamically to the DOM.

When I upload a single file, that is working fine.

It is not a duplicate of Sending multipart/formdata with jQuery.ajax since I already use a FormData object, and my code is the same as the answer. It is still not working as intended.

  • 写回答

2条回答 默认 最新

  • duanbeng1923 2018-02-07 15:53
    关注

    My code is working actually, problem was that post_max_size in the php.ini was too low.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码