ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,777 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello everyone and thanks for the help in advance. I am refactoring a file upload application, but can't get it working:
My HTML:
<form enctype="multipart/form-data" method="post" action="UploadFiles">
<dl>
<dt>
<label></label>
</dt>
<dd>
<input type="file" name="file" id="file" />
<span></span>
</dd>
</dl>
<input type="submit" value="Upload" />
</form>
My Controller
[HttpPost]
public IActionResult UploadFiles(List<IFormFile> postedFiles)
{
return Content("Count=" + postedFiles.Count.ToString());
}
Returns 0. What am I doing wrong?
What am I doing wrong?
public ActionResult Index()
{
return View();
}
[HttpPost]
// FileUpload/UploadFiles
public IActionResult UploadFiles(List<IFormFile> postedFiles)
{
return Content("Count=" + postedFiles.Count.ToString());
}
@{
ViewData["Title"] = "Index";
}
<h1>Index</h1>
<div>
<form enctype="multipart/form-data" method="post" action="/FileUpload/UploadFiles">
<dl>
<dt>
<label></label>
</dt>
<dd>
<input type="file" name="postedFiles" id="file" multiple />
<span></span>
</dd>
</dl>
<input type="submit" value="Upload" />
</form>
</div>
Reference documentation