ajax multiple file upload with php

后端 未结 2 1932
半阙折子戏
半阙折子戏 2021-01-14 06:21

Hey I am uploading files to a chosen folder and right now I have the ability to select and upload just one file. I know how to handle multiple files in php but I am not sur

2条回答
  •  轮回少年
    2021-01-14 07:08

    You can pass multiple files using form data as below

    HTML

    
    

    JS

    var fd = new FormData();
    var files = $("#fuDocument").get(0).files; // this is my file input in which We can select multiple files.
    fd.append("label", "sound");
    
    for (var i = 0; i < files.length; i++) {
        fd.append("UploadedImage" + i, files[i]);
    }
    
    $.ajax({
        type: "POST",
        url: 'Url',
        contentType: false,
        processData: false,
        data: fd,
        success: function (e) {
            alert("success");                    
        }        
     })
    

    Now pass fd object in you ajax call it is working with my code

提交回复
热议问题