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




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条回答 默认 最新


      相关推荐 更多相似问题


      • ¥30 VB6.0操作 webview2内核的浏览器如何精确实现网页弹窗处置
      • ¥15 pr导出的视频打不开,提示“缺少编解码器”怎么解决
      • ¥15 html里js获取php参数值不成功,帮改代码
      • ¥20 如何控制ant design的InputNumber组件 最多输入5位小数
      • ¥15 c语言学生基本信息管理系统
      • ¥100 火车头采集器采集求解
      • ¥88 关于#运行时间 时间重叠 和非重叠#的问题,如何解决?
      • ¥15 C语言,密切接触者追踪
      • ¥20 关于计算机网络问题,请附带讲解
      • ¥30 自动识别图像目标并判断