I need to send multiple files to ASP.net core webApi method.I have tried as shown below.But it always shows as 0 files
.Can you tell me why ?
[Route("api/[controller]/[action]")]
[Consumes("application/json", "application/json-patch+json", "multipart/form-data")]
public class DocumentUploadController : CpcpControllerBase
{
[HttpPost]
public async Task<List<string>> AddDocument(ICollection<IFormFile> files)
{
foreach (var f in files)
{
var stream = f.OpenReadStream();
var name = f.FileName;
}
}
}
Postman :
But I can send 1 file as shown below.It's working fine.
[HttpPost]
public async Task<string> AddDocument(IFormFile file)
{
var stream = file.OpenReadStream();
var name = file.FileName;
}
Replace key file1
by files
in postman. It works for me.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With