Save FormData with File Upload in Angular 5

前端 未结 5 912
鱼传尺愫
鱼传尺愫 2021-01-01 00:49

I am trying to save files along with FormData in Angular 5. I can get the single file, but have no idea how to get all the files uploaded. I have three image files and input

5条回答
  •  情深已故
    2021-01-01 01:27

    Try this code:

    handleFileInput(files){
         for (let j = 0; j < files.length; j++) {
          let data = new FormData();
          let fileItem = files[j]._file;
          console.log(fileItem.name);
          data.append('file', fileItem);
        }
    }
    

提交回复
热议问题