There are many ways to upload files in MVC 6.
Below code is the simplest way I found till now, If I get any other simpler method then I will update this code.
view (cshtml) :
<form method="post" asp-action="Upload" asp-controller="Home" enctype="multipart/form-data">
<input type="file" name="file" />
<input type="submit" value="upload"/>
</form>
controller (cs) :
[HttpPost]
public IActionResult Upload(IFormFile file)
{
if (file == null || file.Length == 0)
throw new Exception("file should not be null");
var originalFileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');
file.SaveAs("your_file_full_address");
}
Happy coding!