create FormData instance for each file in <input type=file multiple>

前端 未结 2 1130
无人共我
无人共我 2021-01-14 04:20

I\'m trying to use input file with multiple attribute and to have the formData split so I would have a formData isnatce for each file in the multiple file eleme

2条回答
  •  野的像风
    2021-01-14 04:48

    Each time you make a formData object you can append to it data like this:

    data.append("file", document.getElementById(file).files[0]);
    

    but instead of 0 in for loop you can put loop index and send data to ajax.

    and you should initialize data by following :

     var data = new FormData();
    

提交回复
热议问题