get bad request when upload multiple files #956

Open
opened 2018-01-08 16:05:10 +00:00 by abas1991 · 1 comment
abas1991 commented 2018-01-08 16:05:10 +00:00 (Migrated from github.com)

hi
i use angular 4 an .net core, in angular i have this:
files: FormData = new FormData();
.
.
for (let file of event.files) {
this.files.append("files", file, file.FileName);
}
.
.
postImages:void{
this.http.post(this.baseUrl + "/api/services/app/MyService/PostFiles", this.files).subscribe(result => {
});
}

and in .net core web api:
public async Task PostFiles(IFormFile[] files)
{
..
}

when i post my request to .net core web api i get bad request error!

in single file post everything work well , in .net core web api i have this:
public async Task PostFiles(IFormFile file)

hi i use angular 4 an .net core, in angular i have this: files: FormData = new FormData(); . . for (let file of event.files) { this.files.append("files", file, file.FileName); } . . postImages:void{ this.http.post(this.baseUrl + "/api/services/app/MyService/PostFiles", this.files).subscribe(result => { }); } and in .net core web api: public async Task<int> PostFiles(IFormFile[] files) { .. } when i post my request to .net core web api i get bad request error! in single file post everything work well , in .net core web api i have this: public async Task<int> PostFiles(IFormFile file)
Serebryakov-A commented 2019-02-27 10:51:13 +00:00 (Migrated from github.com)

use List<IFormFile> files for multiple files

use `List<IFormFile> files` for multiple files
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dc/ng2-file-upload#956