[英]Upload file from angular to asp.net core web api controller
How to Upload File from Angular to ASP.NET Core Web API 如何从Angular上传文件到ASP.NET核心Web API
I wanted to know how to write it's controller part can anyone help me in that?我想知道如何编写它的 controller 部分,有人可以帮助我吗?
What to right inside controller里面有什么 controller
Angular simple example: https://codesandbox.io/s/jolly-montalcini-49h53n?file=/src/app/app.component.html Look App Folder Angular 简单例子: https://codesandbox.io/s/jolly-montalcini-49h53n?file=/src/app/app.component.html查看App文件夹
Web Api Controller: Object Rq: Web Api Controller: Object Rq:
public class UploadFileRq
{
public IFormFile File { get; set; }
}
Controller: Controller:
[HttpPut("yourUrl")]
public async Task<IActionResult> UploadFile([FromForm] UploadFileRq file)
{
// your process here
return Ok();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.