# 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.

Namespace: [Radzen.Blazor](https://blazor.radzen.com/docs/api/Radzen.Blazor.md)

Assembly: Radzen.Blazor.dll

## Inheritance

- Object
- ComponentBase
- [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md)
- [FormComponent<TValue>](https://blazor.radzen.com/docs/api/Radzen.FormComponent-1.md)
- RadzenFileInput<TValue>

## Implements

- IComponent
- IHandleEvent
- IHandleAfterRender
- [IRadzenFormComponent](https://blazor.radzen.com/docs/api/Radzen.IRadzenFormComponent.md)

## Syntax

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

## Type Parameters

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

## Examples

File input binding to string (base64):

```razor
<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:

```razor
<RadzenFileInput @bind-Value=@fileContent TValue="byte[]" Accept="image/*" MaxFileSize="2000000" />
@code {
    byte[] fileContent;
}
```

## Constructors

| Constructor | Description |
|-------------|-------------|
| `public RadzenFileInput<TValue>()` | 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. |

## Fields

| Field | Type | Description |
|------|------|-------------|
| fileUpload | `ElementReference` | Gets file input reference. |

## Properties

| Property | Type | Description |
|------|------|-------------|
| Accept | `string` | Gets or sets the comma-separated accepted MIME types. |
| ChooseText | `string` | Gets or sets the choose button text. |
| DeleteText | `string` | Gets or sets the delete button text. |
| Error | `EventCallback<UploadErrorEventArgs>` | Gets or sets the error callback. |
| FileName | `string` | Gets or sets the image file name. |
| FileNameChanged | `EventCallback<string>` | Gets or sets the FileName changed. |
| FileSize | `long?` | Gets or sets the image file size. |
| FileSizeChanged | `EventCallback<long?>` | Gets or sets the FileSize changed. |
| ImageAlternateText | `string` | Gets or sets the text. |
| ImageClick | `EventCallback<MouseEventArgs>` | Gets or sets the image click callback. |
| ImageStyle | `string` | Gets or sets the image style. |
| InputAttributes | `IReadOnlyDictionary<string, object>` | Specifies additional custom attributes that will be rendered by the input. |
| MaxFileSize | `int` | Gets or sets the maximum size of the file. |
| MaxHeight | `int` | Gets or sets the maximum height of the file, keeping aspect ratio. |
| MaxWidth | `int` | Gets or sets the maximum width of the file, keeping aspect ratio. |
| Title | `string` | Gets or sets the title. |

## Methods

| Method | Returns | Description |
|------|---------|-------------|
| `BuildRenderTree(Rendering.RenderTreeBuilder __builder)` | `void` |  |
| `Dispose()` | `void` |  |
| `GetComponentCssClass()` | `string` |  |
| `OnAfterRenderAsync(bool firstRender)` | `Task` |  |
| `OnChange(IEnumerable<PreviewFileInfo> files)` | `Task` | Called on file change. Parameters: `files`: The file. |
| `OnImageClick(MouseEventArgs args)` | `Task` | Handles the image click event. Parameters: `args`: The MouseEventArgs instance containing the event data. |
| `SetParametersAsync(ParameterView parameters)` | `Task` |  |

## Inherited Members

- From [FormComponent<TValue>](https://blazor.radzen.com/docs/api/Radzen.FormComponent-1.md): Change, CurrentPlaceholder, Disabled, EditContext, FieldIdentifier, FocusAsync, Form, FormFieldContext, FormFieldLabelledBy, GetClassList, GetValue, HasValue, IsBound, LabelTargetId, LabelToLink, LinkLabelAsync, Name, NotifyFieldChanged, OnContextMenu, Placeholder, ShouldLinkLabel, TabIndex, Value, ValueChanged, ValueExpression, _value
- From [RadzenComponent](https://blazor.radzen.com/docs/api/Radzen.RadzenComponent.md): AddContextMenu, Attributes, ContextMenu, Culture, CurrentStyle, Debounce, DefaultCulture, DefaultUICulture, Element, GetCssClass, GetId, GetIdAttribute, IsJSRuntimeAvailable, JSRuntime, Localize, MouseEnter, MouseLeave, OnBecameInvisible, OnInitialized, OnMouseEnter, OnMouseLeave, RaiseContextMenu, RaiseMouseEnter, RaiseMouseLeave, Reference, Style, UICulture, UniqueID, Visible
- From ComponentBase: Assets, AssignedRenderMode, DispatchExceptionAsync, InvokeAsync, OnAfterRender, OnInitializedAsync, OnParametersSet, OnParametersSetAsync, RendererInfo, ShouldRender, StateHasChanged

