-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Closed
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components
Milestone
Description
I'm trying to clear the list of files displayed by the component after the files are uploaded but the component provides no means of doing so (at least as far as I could find).
<InputFile OnChange="(e) => selectedFiles = e.GetMultipleFiles().ToList()" multiple />
<button @onclick="@SaveWholeForm()">Save</button>
@code {
List<IBrowserFile> selectedFiles;
void SaveWholeForm() {
// save stuff
using var content = new MultipartFormDataContent();
foreach (var file in selectedFiles)
{
var fileContent = new StreamContent(file.OpenReadStream(1024 * 1024 * 100));
content.Add(
content: fileContent,
name: "\"files\"",
fileName: file.Name
);
}
await httpClient.PostAsync($"/api/File/{Id}", content);
// Need to clear the file list in some way
}
}
I'd prefer it if the collection of files could be bound to a c# List or Array so it could be cleared or otherwise manipulated. Obviously I can use javascript but this feels like a workaround.
Metadata
Metadata
Assignees
Labels
area-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor Components