RadzenFileInput<TValue> Class

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.

Inheritance

Object

ComponentBase

RadzenComponent

FormComponent<TValue>

RadzenFileInput<TValue>

Implements

IComponent

IHandleEvent

IHandleAfterRender

IRadzenFormComponent

Inherited Members

FormComponent<TValue>.Dispose

FormComponent<TValue>.GetValue

FormComponent<TValue>.OnContextMenu

FormComponent<TValue>.GetClassList

FormComponent<TValue>.FocusAsync

FormComponent<TValue>.Name

FormComponent<TValue>.TabIndex

FormComponent<TValue>.Placeholder

FormComponent<TValue>.Disabled

FormComponent<TValue>.EditContext

FormComponent<TValue>.Form

FormComponent<TValue>.ValueChanged

FormComponent<TValue>.HasValue

FormComponent<TValue>.IsBound

FormComponent<TValue>.Value

FormComponent<TValue>.Change

FormComponent<TValue>.FieldIdentifier

FormComponent<TValue>.ValueExpression

FormComponent<TValue>.FormFieldContext

FormComponent<TValue>.CurrentPlaceholder

FormComponent<TValue>._value

RadzenComponent.OnMouseEnter

RadzenComponent.OnMouseLeave

RadzenComponent.GetCssClass

RadzenComponent.GetId

RadzenComponent.Debounce

RadzenComponent.OnInitialized

RadzenComponent.RaiseContextMenu

RadzenComponent.RaiseMouseEnter

RadzenComponent.AddContextMenu

RadzenComponent.RaiseMouseLeave

RadzenComponent.OnBecameInvisible

RadzenComponent.Attributes

RadzenComponent.Element

RadzenComponent.MouseEnter

RadzenComponent.MouseLeave

RadzenComponent.ContextMenu

RadzenComponent.Culture

RadzenComponent.DefaultCulture

RadzenComponent.Style

RadzenComponent.Visible

RadzenComponent.UniqueID

RadzenComponent.JSRuntime

RadzenComponent.IsJSRuntimeAvailable

RadzenComponent.Reference

RadzenComponent.CurrentStyle

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

Syntax

public class RadzenFileInput<TValue> : FormComponent<TValue>, IComponent, IHandleEvent, IHandleAfterRender, IRadzenFormComponent

Type Parameters

Name Description
TValueThe type of the bound value. Use string for base64-encoded content or byte[] for binary data.

Examples

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;
}

Constructors

RadzenFileInput<TValue>link

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.

Declaration
public RadzenFileInput<TValue>()

Fields

fileUploadlink

Gets file input reference.

Declaration
protected ElementReference fileUpload

Properties

Acceptlink

Gets or sets the comma-separated accepted MIME types.

Declaration
public string Accept { get; set; }
Property Value
Type Description
stringGets or sets the comma-separated accepted MIME types.

ChooseTextlink

Gets or sets the choose button text.

Declaration
public string ChooseText { get; set; }
Property Value
Type Description
stringGets or sets the choose button text.

DeleteTextlink

Gets or sets the delete button text.

Declaration
public string DeleteText { get; set; }
Property Value
Type Description
stringGets or sets the delete button text.

Errorlink

Gets or sets the error callback.

Declaration
public EventCallback<UploadErrorEventArgs> Error { get; set; }
Property Value
Type Description
EventCallback<UploadErrorEventArgs>Gets or sets the error callback.

FileNamelink

Gets or sets the image file name.

Declaration
public string FileName { get; set; }
Property Value
Type Description
stringGets or sets the image file name.

FileNameChangedlink

Gets or sets the FileName changed.

Declaration
public EventCallback<string> FileNameChanged { get; set; }
Property Value
Type Description
EventCallback<string>Gets or sets the FileName changed.

FileSizelink

Gets or sets the image file size.

Declaration
public long? FileSize { get; set; }
Property Value
Type Description
long?Gets or sets the image file size.

FileSizeChangedlink

Gets or sets the FileSize changed.

Declaration
public EventCallback<long?> FileSizeChanged { get; set; }
Property Value
Type Description
EventCallback<long?>Gets or sets the FileSize changed.

ImageAlternateTextlink

Gets or sets the text.

Declaration
public string ImageAlternateText { get; set; }
Property Value
Type Description
stringGets or sets the text.

ImageClicklink

Gets or sets the image click callback.

Declaration
public EventCallback<MouseEventArgs> ImageClick { get; set; }
Property Value
Type Description
EventCallback<MouseEventArgs>Gets or sets the image click callback.

ImageStylelink

Gets or sets the image style.

Declaration
public string ImageStyle { get; set; }
Property Value
Type Description
stringGets or sets the image style.

InputAttributeslink

Specifies additional custom attributes that will be rendered by the input.

Declaration
public IReadOnlyDictionary<string, object> InputAttributes { get; set; }
Property Value
Type Description
IReadOnlyDictionary<string, object>Specifies additional custom attributes that will be rendered by the input.

MaxFileSizelink

Gets or sets the maximum size of the file.

Declaration
public int MaxFileSize { get; set; }
Property Value
Type Description
intGets or sets the maximum size of the file.

MaxHeightlink

Gets or sets the maximum height of the file, keeping aspect ratio.

Declaration
public int MaxHeight { get; set; }
Property Value
Type Description
intGets or sets the maximum height of the file, keeping aspect ratio.

MaxWidthlink

Gets or sets the maximum width of the file, keeping aspect ratio.

Declaration
public int MaxWidth { get; set; }
Property Value
Type Description
intGets or sets the maximum width of the file, keeping aspect ratio.

Titlelink

Gets or sets the title.

Declaration
public string Title { get; set; }
Property Value
Type Description
stringGets or sets the title.

Methods

BuildRenderTreelink

Declaration
protected override void BuildRenderTree(Rendering.RenderTreeBuilder __builder)
Parameters
Type Name Description
Rendering.RenderTreeBuilder __builder

GetComponentCssClasslink

Declaration
protected override string GetComponentCssClass()
Returns
Type Description
string

OnAfterRenderAsynclink

Declaration
protected override Task OnAfterRenderAsync(bool firstRender)
Parameters
Type Name Description
bool firstRender
Returns
Type Description
Task

OnChangelink

Called on file change.

Declaration
public Task OnChange(IEnumerable<PreviewFileInfo> files)
Parameters
Type Name Description
IEnumerable<PreviewFileInfo> files The file.
Returns
Type Description
Task

OnImageClicklink

Handles the image click event.

Declaration
public Task OnImageClick(MouseEventArgs args)
Parameters
Type Name Description
MouseEventArgs args The MouseEventArgs instance containing the event data.
Returns
Type Description
Task

SetParametersAsynclink

Declaration
public override Task SetParametersAsync(ParameterView parameters)
Parameters
Type Name Description
ParameterView parameters
Returns
Type Description
Task
An error has occurred. This app may no longer respond until reloaded. Reload 🗙