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

  • duanbeng1923 2018-02-07 15:53

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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?



  • ¥18 深度学习tensorflow1,ssdv1,coco数据集训练一个模型
  • ¥100 关于注册表摄像头和麦克风的问题
  • ¥30 代码本地运行正常,但是TOMCAT部署时闪退
  • ¥15 关于#python#的问题
  • ¥15 主机可以ping通路由器但是连不上网怎么办
  • ¥15 数据库一张以时间排好序的表中,找出多次相邻的那些行
  • ¥50 关于DynamoRIO处理多线程程序时候的问题
  • ¥15 kubeadm部署k8s出错
  • ¥15 Abaqus打不开cae文件怎么办?
  • ¥15 小程序准备上线,软件开发公司需要提供哪些资料给甲方