Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Manage files in the InputFile component, Blazor WASM

$
0
0

Before allowing a user to save files I want to check some file preconditions: name, size, etc. And if some file does not meet requirements then remove it from the list to save.

<div class="col-sm-10"><InputFile multiple OnChange="OnInputFileChange" /></div>@code {    private async Task OnInputFileChange(InputFileChangeEventArgs e)    {        IReadOnlyList<IBrowserFile> files = e.GetMultipleFiles(20);        foreach (IBrowserFile imageFile in files)        {             if (imageFile.Size > PhotoMaxBytes)             {               **REMOVE FILE FROM files**             }            ...        }    }}

But as I see method GetMultipleFiles returns IReadOnlyList<> and I cannot remove a file from this collection. Is there a way to do it and if not how can I clear files in the InputFile component from code? I mean if one file does not meet requirements just remove all files from InputFile. Cannot see any suitable method in the InputFileChangeEventArgs.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>