Sam*_*ath 3 c# asp.net asp.net-core-mvc asp.net-core
我需要发送多个文件到ASP.net核心webApi方法.我已经尝试过如下所示.但它总是显示为0 files
.你能告诉我为什么?
[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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
邮差:
但我可以发送1个文件,如下所示.它工作正常.
[HttpPost]
public async Task<string> AddDocument(IFormFile file)
{
var stream = file.OpenReadStream();
var name = file.FileName;
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
4442 次 |
最近记录: |