The problem I am having is that the List of IFormFile is not being populated with the given files but when i call HttpContext.Request.Form.Files; then I have access to the files. I would prefer to use IFormFile as it seems to be new Dotnet core 2.0 way of doing things.
I have the following request payload:
With the following request headers:
And Razor pages handler:
public async Task<ActionResult> OnPostSend(ConditionResponse conditionResponse)
{
var files = HttpContext.Request.Form.Files;
}
Condition response model:
public class ConditionResponse
{
public List<string> Plots { get; set; }
public string Comments { get; set; }
public List<IFormFile> Files { get; set; }
}
The accepted answer worked perfectly, I am not sure why and how, but it works. I just wanted to get rid of that additional function, i.e., we can use it like this:
Or if old browsers are also targeted:
After looking at the request from a html5 multiple file upload I noticed the request does not add the indexes to the filename (files[n]). Dropzone.js does this so there is a work around. If you add the paramName option to Dropzone JS config and have it call a method which returns files you will get the same behaviour as the html5 multiple file upload.