Save FormData with File Upload in Angular 5

前端 未结 5 920
鱼传尺愫
鱼传尺愫 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:22

    This is what I tried and it worked as expected :

    handleCategoryBanner(files: FileList) {
        this.category.category_banner = '/categories/download/' + files[0].name;
        this.formData.append('category_banner', files[0], files[0].name);
        this.categoryContainersService.uploadFile(this.formData).subscribe(filename => console.log(files[0].name));
      }

提交回复
热议问题