I'm trying to write a web page (ASP.NET Core) to allow users to upload files. My use case however requires the users to potentially select files from multiple locations.
I've written a page that allows users to upload multiple files from a single folder using
IFormFile
control, my understanding being you can't select files from multiple folders
<form method="post" enctype="multipart/form-data">
<input type="file" asp-for="Upload" multiple />
<span asp-validation-for="Upload" />
<input type="submit" />
</form>
Code Behind File
[BindProperty]
public List<IFormFile> Upload { get; set; }
public async Task OnPostAsync()
{
foreach (var file in Upload)
{
// ToDo - Copy file to temp location
}
}
What I would like to do is copy the files to a temp location (as indicated) and present the user with a list of the uploaded files and the opportunity to upload more files (from different folders). Once complete, the user would then submit that list to be processed.
I've having a little trouble in working out the best way to persist the list of files submitted between each call back to the page.
Thanks in advance
CodePudding user response: