asp.net – 为什么IFormFile显示为null,我该如何解决?
发布时间:2020-05-25 04:19:13 所属栏目:asp.Net 来源:互联网
导读:我在VS 2015中使用ASP.NET 5,MVC 6.我正在制作一个Web应用程序.在我的表格上我有: form method=post enctype=multipart/form-data div id=uploadSection label Select files for upload/label input typ
|
我在VS 2015中使用ASP.NET 5,MVC 6.我正在制作一个Web应用程序.在我的表格上我有: <form method="post" enctype="multipart/form-data">
<div id="uploadSection" >
<label >Select files for upload</label>
<input type="file" id="fileSelect" name="fileSelect" multiple />
</div>
<div>
<input type="submit" id="thisbutton" value="button" />
</div>
</form>
在我的控制器中: [HttpPost]
public async Task<IActionResult> FileForm(FileViewModel vm,IFormFile file)
{
if (ModelState.IsValid)
{
//IFormFileCollection files = Request.Form.Files;
string filePath = Path.Combine("C:","transfers");
//foreach (var file in files)
//{
if (file != null && file.Length > 0)
{
var fileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
await file.SaveAsAsync(Path.Combine(filePath,fileName));
}
/ |
相关内容
推荐文章
站长推荐
- asp.net – 问题映射HttpHandler – HTTP错误404
- asp.net – 使用Razor有点像回到经典的asp
- asp.net – 在什么情况下,.NET进程和AppDomains在
- asp.net-mvc – 修改ActionFilter中的模型
- asp.net-web-api – WebApi2属性路由404
- asp.net – HTML属性bgcolor已被弃用:使用什么?
- ASP.NET中的SMTP头注入?
- asp.net-mvc – 在ascx文件中使用Html.RenderPar
- asp.net – VirtualPath位于当前应用程序根目录之
- asp.net – ActivationManager构建过程中的异常?
热点阅读
