A file input component that reads selected files and binds their content as base64 strings or byte arrays. RadzenFileInput provides client-side file reading without server upload, ideal for form fields or immediate file processing. Unlike RadzenUpload which sends files to a server, FileInput reads files on the client and binds the content to a property. Useful for form integration (including file content in form models without separate upload), client-side processing (processing files in browser for image preview, parsing, etc.), embedded storage (storing file content in database as base64 or binary), and avoiding server-side upload endpoints when file content is part of form data. Reads the selected file and binds it as TValue = string for base64-encoded data URL (e.g., "data:image/png;base64,iVBORw0K...") or TValue = byte[] for raw binary file content. For image files, automatically shows a preview. Use MaxFileSize to limit file size.
FormComponent<TValue>.GetValue
FormComponent<TValue>.OnContextMenu
FormComponent<TValue>.GetClassList
FormComponent<TValue>.FocusAsync
FormComponent<TValue>.TabIndex
FormComponent<TValue>.Placeholder
FormComponent<TValue>.Disabled
FormComponent<TValue>.EditContext
FormComponent<TValue>.ValueChanged
FormComponent<TValue>.HasValue
FormComponent<TValue>.FieldIdentifier
FormComponent<TValue>.ValueExpression
FormComponent<TValue>.FormFieldContext
FormComponent<TValue>.CurrentPlaceholder
RadzenComponent.RaiseContextMenu
RadzenComponent.RaiseMouseEnter
RadzenComponent.AddContextMenu
RadzenComponent.RaiseMouseLeave
RadzenComponent.OnBecameInvisible
RadzenComponent.DefaultCulture
RadzenComponent.IsJSRuntimeAvailable
ComponentBase.OnInitializedAsync
ComponentBase.OnParametersSet
ComponentBase.OnParametersSetAsync
ComponentBase.StateHasChanged
ComponentBase.ShouldRender
ComponentBase.OnAfterRender
ComponentBase.InvokeAsync
ComponentBase.DispatchExceptionAsync
ComponentBase.RendererInfo
ComponentBase.Assets
ComponentBase.AssignedRenderMode
Namespace: Radzen.Blazor
Assembly: Radzen.Blazor.dll
public class RadzenFileInput<TValue> : FormComponent<TValue>, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormComponent| Name | Description |
|---|---|
| TValue | The type of the bound value. Use string for base64-encoded content or byte[] for binary data. |
File input binding to string (base64):
<RadzenFileInput @bind-Value=@model.PhotoData TValue="string" />
@code {
class Employee
{
public string PhotoData { get; set; } // Contains base64 image data
}
Employee model = new Employee();
}
File input binding to byte array:
<RadzenFileInput @bind-Value=@fileContent TValue="byte[]" Accept="image/*" MaxFileSize="2000000" />
@code {
byte[] fileContent;
}A file input component that reads selected files and binds their content as base64 strings or byte arrays. RadzenFileInput provides client-side file reading without server upload, ideal for form fields or immediate file processing. Unlike RadzenUpload which sends files to a server, FileInput reads files on the client and binds the content to a property. Useful for form integration (including file content in form models without separate upload), client-side processing (processing files in browser for image preview, parsing, etc.), embedded storage (storing file content in database as base64 or binary), and avoiding server-side upload endpoints when file content is part of form data. Reads the selected file and binds it as TValue = string for base64-encoded data URL (e.g., "data:image/png;base64,iVBORw0K...") or TValue = byte[] for raw binary file content. For image files, automatically shows a preview. Use MaxFileSize to limit file size.
public RadzenFileInput<TValue>()Gets or sets the comma-separated accepted MIME types.
public string Accept { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the comma-separated accepted MIME types. |
Gets or sets the choose button text.
public string ChooseText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the choose button text. |
Gets or sets the delete button text.
public string DeleteText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the delete button text. |
Gets or sets the error callback.
public EventCallback<UploadErrorEventArgs> Error { get; set; }
| Type | Description |
|---|---|
| EventCallback<UploadErrorEventArgs> | Gets or sets the error callback. |
Gets or sets the image file name.
public string FileName { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the image file name. |
Gets or sets the FileName changed.
public EventCallback<string> FileNameChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<string> | Gets or sets the FileName changed. |
Gets or sets the image file size.
public long? FileSize { get; set; }
| Type | Description |
|---|---|
| long? | Gets or sets the image file size. |
Gets or sets the FileSize changed.
public EventCallback<long?> FileSizeChanged { get; set; }
| Type | Description |
|---|---|
| EventCallback<long?> | Gets or sets the FileSize changed. |
Gets or sets the text.
public string ImageAlternateText { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the text. |
Gets or sets the image click callback.
public EventCallback<MouseEventArgs> ImageClick { get; set; }
| Type | Description |
|---|---|
| EventCallback<MouseEventArgs> | Gets or sets the image click callback. |
Gets or sets the image style.
public string ImageStyle { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the image style. |
Specifies additional custom attributes that will be rendered by the input.
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }
| Type | Description |
|---|---|
| IReadOnlyDictionary<string, object> | Specifies additional custom attributes that will be rendered by the input. |
Gets or sets the maximum size of the file.
public int MaxFileSize { get; set; }
| Type | Description |
|---|---|
| int | Gets or sets the maximum size of the file. |
Gets or sets the maximum height of the file, keeping aspect ratio.
public int MaxHeight { get; set; }
| Type | Description |
|---|---|
| int | Gets or sets the maximum height of the file, keeping aspect ratio. |
Gets or sets the maximum width of the file, keeping aspect ratio.
public int MaxWidth { get; set; }
| Type | Description |
|---|---|
| int | Gets or sets the maximum width of the file, keeping aspect ratio. |
Gets or sets the title.
public string Title { get; set; }
| Type | Description |
|---|---|
| string | Gets or sets the title. |
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
| Type | Name | Description |
|---|---|---|
| Rendering.RenderTreeBuilder | __builder |
protected override string GetComponentCssClass()
| Type | Description |
|---|---|
| string |
protected override Task OnAfterRenderAsync(bool firstRender)
| Type | Name | Description |
|---|---|---|
| bool | firstRender |
| Type | Description |
|---|---|
| Task |
Called on file change.
public Task OnChange(IEnumerable<PreviewFileInfo> files)
| Type | Name | Description |
|---|---|---|
| IEnumerable<PreviewFileInfo> | files | The file. |
| Type | Description |
|---|---|
| Task |
Handles the image click event.
public Task OnImageClick(MouseEventArgs args)
| Type | Name | Description |
|---|---|---|
| MouseEventArgs | args | The MouseEventArgs instance containing the event data. |
| Type | Description |
|---|---|
| Task |
public override Task SetParametersAsync(ParameterView parameters)
| Type | Name | Description |
|---|---|---|
| ParameterView | parameters |
| Type | Description |
|---|---|
| Task |