-
Book Overview & Buying
-
Table Of Contents
Blazor WebAssembly by Example - Third Edition
By :
The InputFile component is a built-in component that provides the foundation for file uploads in Blazor WebAssembly. It renders an HTML input element of type file and provides a stream for reading the contents of the selected file. The component is defined in the Microsoft.AspNetCore.Components.Forms namespace.
The OnChange event of the InputFile component specifies the callback that runs when a file is selected. The following example shows an InputFile component that invokes the OnChangeHandler method when a file is selected:
<InputFile OnChange="OnChangeHandler" accept="image/png, image/jpeg" />
This is the resulting HTML markup from the preceding example:
<input accept="image/png, image/jpeg" type="file" _bl_2="">
In the preceding HTML markup, the _bl_2 attribute is used for Blazor's internal processing, but everything else is a typical input element. The accept attribute is used to filter the types...