if I call the POST action method I want to get the data from the files-object of my GET action method.
public class UploadController:Controller {
public IActionResult Index(){
// Here is some code
return View(files);
}
[HttpPost]
public IActionResult Index(IFormFile importFile){
{
// Here I want to work with data from the files object of my Index() method above
return View("Index", newFiles);
}
}
My View looks like this:
@using MVC-project.Models
@model UploadViewModel
<table>
<tr>
<th>File Name</th>
<th></th>
</tr>
@foreach (string file in Model.FileName )
{
<tr>
<td>@file</td>
<td>@Html.ActionLink("Download", "DownloadFile", new { fileName = file })</td>
</tr>
}
</table>
@using (Html.BeginForm("Index", "Upload", FormMethod.Post, new { @id = "upldFrm", @enctype = "multipart/form-data" }))
{
<div class="row">
<div class="form-group col-md-6">
<input type="file" class=" form-control" name="importFile" />
</div>
<div class="form-group col-md-6">
<input type="submit" name="filesubmit" value="Upload" />
</div>
</div>
}
// Here is some code and if-case for processing after the POST submit
How can I use the data from the files object of my GET Index() action method in my POST Index method?