# RadzenUpload Class

A file upload component with progress tracking, multiple file support, and drag-and-drop capability. RadzenUpload provides a full-featured file upload interface with automatic or manual upload, server communication, and comprehensive event handling. Handles file selection and upload to a server endpoint with automatic upload on file selection or manual triggering via Upload() method, real-time upload progress with percentage and bytes loaded, file type restriction via Accept property (MIME types or extensions), custom authentication or HTTP headers, Complete/Error/Progress/Change events for tracking upload lifecycle, automatic image preview for image files, file removal support, and built-in drag-and-drop for file selection. Uploads files to the URL endpoint via HTTP POST multipart/form-data. Server-side endpoint must accept file uploads and return appropriate responses.

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)
- RadzenUpload

## Implements

- IComponent
- IHandleEvent
- IHandleAfterRender

## Syntax

```csharp
public class RadzenUpload : RadzenComponent, IComponent, IHandleEvent, IHandleAfterRender
```

## Examples

Basic upload with auto-upload:

```razor
<RadzenUpload Url="api/upload" Change=@OnChange Complete=@OnComplete />
@code {
    void OnChange(UploadChangeEventArgs args)
        => Console.WriteLine($"Selected {args.Files?.Count() ?? 0} files");

    void OnComplete(UploadCompleteEventArgs args)
        => Console.WriteLine(args.Cancelled ? "Upload cancelled" : "Upload complete");
}
```

Manual upload with progress tracking:

```razor
<RadzenUpload @ref=upload Url="api/upload" Auto="false" Multiple="true" Progress=@OnProgress />
<RadzenButton Text="Upload" Click=@(() => upload.Upload()) />
@code {
    RadzenUpload upload;
    void OnProgress(UploadProgressArgs args)
    {
        Console.WriteLine($"Progress: {args.Progress}% ({args.Loaded}/{args.Total} bytes)");
    }
}
```

Upload with file type filtering:

```razor
<RadzenUpload Url="api/upload/images" Accept="image/*" MaxFileSize="5000000" />
```

## Constructors

| Constructor | Description |
|-------------|-------------|
| `public RadzenUpload()` | A file upload component with progress tracking, multiple file support, and drag-and-drop capability. RadzenUpload provides a full-featured file upload interface with automatic or manual upload, server communication, and comprehensive event handling. Handles file selection and upload to a server endpoint with automatic upload on file selection or manual triggering via Upload() method, real-time upload progress with percentage and bytes loaded, file type restriction via Accept property (MIME types or extensions), custom authentication or HTTP headers, Complete/Error/Progress/Change events for tracking upload lifecycle, automatic image preview for image files, file removal support, and built-in drag-and-drop for file selection. Uploads files to the URL endpoint via HTTP POST multipart/form-data. Server-side endpoint must accept file uploads and return appropriate responses. |

## Fields

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

## Properties

| Property | Type | Description |
|------|------|-------------|
| Accept | `string` | Gets or sets the accepted MIME types. |
| AllowedExtensions | `IEnumerable<string>` | Gets or sets allowed filename suffixes, such as ".pdf" or ".tar.gz". Requires Url. Null or an empty collection allows all extensions. Comparison is case-insensitive and a missing leading dot is added. Applies to new selections only and does not validate MIME types or file contents. |
| AppendFiles | `bool` | Gets or sets whether new selections are appended instead of replacing selected files. Applies only with Url, Multiple=true, Auto=false and Stream=false. Otherwise ignored. Repeated selections are separate entries. Uploading does not clear the selection. |
| Auto | `bool` | Gets or sets a value indicating whether this [RadzenUpload](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenUpload.md) upload is automatic. |
| Change | `EventCallback<UploadChangeEventArgs>` | Gets or sets the change callback. |
| ChildContent | `RenderFragment` | Gets or sets the child content. |
| ChooseTemplate | `RenderFragment` | Gets or sets the content of the file selection area. Replaces the default icon and text. Use non-interactive content. The entire area selects files and supports drag and drop. ChooseText remains the accessible name of the selection area. |
| ChooseText | `string` | Gets or sets the choose button text. |
| Complete | `EventCallback<UploadCompleteEventArgs>` | Gets or sets the complete callback. |
| DeleteText | `string` | Gets or sets the choose button text. |
| Disabled | `bool` | Gets or sets a value indicating whether this [RadzenUpload](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenUpload.md) is disabled. |
| Error | `EventCallback<UploadErrorEventArgs>` | Gets or sets the error callback. |
| HasValue | `bool` | Gets a value indicating whether this instance has value. |
| Icon | `string` | Gets or sets the icon. |
| IconColor | `string` | Gets or sets the icon color. |
| ImageAlternateText | `string` | Gets or sets the text. |
| InputAttributes | `IReadOnlyDictionary<string, object>` | Specifies additional custom attributes that will be rendered by the input. |
| MaxFileCount | `int` | Gets or sets the maximum number of files. |
| MaxFileSize | `long?` | Gets or sets the maximum size in bytes for newly selected files. Requires Url. Null means no size limit. Files whose size equals the limit are allowed. This client-side check does not replace server-side validation. |
| Method | `string` | Specifies the HTTP method used for uploading files to the defined Url endpoint. Common values are POST (default) and PUT. If the parameter is not set, this property is ignored. Defaults to POST. |
| Multiple | `bool` | Gets or sets a value indicating whether this [RadzenUpload](https://blazor.radzen.com/docs/api/Radzen.Blazor.RadzenUpload.md) is multiple. |
| Name | `string` | Gets or sets the name. |
| ParameterName | `string` | Gets or sets the parameter name. If not set 'file' parameter name will be used for single file and 'files' for multiple files. |
| Progress | `EventCallback<UploadProgressArgs>` | Gets or sets the progress callback. |
| Rejected | `EventCallback<UploadRejectedEventArgs>` | Gets or sets the callback reporting files rejected by the client-side selection limits. This notification does not delay or cancel upload of accepted files. |
| ShowFileList | `bool` | Gets or sets whether the selected file list is displayed. Defaults to true. Hiding the list does not clear selected files or change upload behavior. |
| Stream | `bool` | Enables streaming upload mode for large files to the specified Url. When true, files are uploaded as raw binary streams instead of multipart/form-data. Only a single file can be uploaded at a time in streaming mode. When false (default), files are uploaded as multipart/form-data (standard form upload), and multiple files can be uploaded simultaneously if is enabled. This property is ignored if is not set. |
| TabIndex | `int` | Gets or sets the tab order index for keyboard navigation. Controls the order in which the Choose button receives focus when the user presses the Tab key. Lower values receive focus first. Use -1 to exclude from tab navigation. |
| Url | `string` | Gets or sets the URL. |

## Methods

| Method | Returns | Description |
|------|---------|-------------|
| `BuildRenderTree(Rendering.RenderTreeBuilder __builder)` | `void` |  |
| `ClearFiles()` | `Task` | Clear selected file(s) from the upload selection |
| `CreateUploadChangeEventArgs(IEnumerable<FileInfo> files)` | [`UploadChangeEventArgs`](https://blazor.radzen.com/docs/api/Radzen.UploadChangeEventArgs.md) | Creates the upload change event args. |
| `Dispose()` | `void` |  |
| `GetComponentCssClass()` | `string` |  |
| `GetHeaders()` | `IDictionary<string, string>` | Gets the headers. Returns: IDictionary<System.String, System.String>. |
| `OnAfterRenderAsync(bool firstRender)` | `Task` |  |
| `OnChange(IEnumerable<PreviewFileInfo> files)` | `Task` | Called on file change. Parameters: `files`: The files. |
| `OnComplete(string response, bool cancelled)` | `Task` | Called when upload is complete. Parameters: `response`: The response. `cancelled`: Flag indicating if the upload was cancelled |
| `OnError(string error)` | `Task` | Called on upload error. Parameters: `error`: The error. |
| `OnParametersSet()` | `void` |  |
| `OnProgress(int progress, long loaded, long total, IEnumerable<FileInfo> files, bool cancel)` | `Task<bool>` | Called on progress. Parameters: `progress`: The progress. `loaded`: The loaded. `total`: The total. `files`: The files. `cancel`: The cancelled state. |
| `OnQueueChange(IEnumerable<PreviewFileInfo> files, long version)` | `Task` | Receives an ordered snapshot of the browser upload selection. |
| `OnRejected(UploadRejectedEventArgs args)` | `Task` | Reports files rejected by client-side selection limits. |
| `OnRemove(PreviewFileInfo file, bool fireChangeEvent)` | `Task` | Called on file remove. Parameters: `file`: The file. `fireChangeEvent`: If the linked Change event should be fired as a result of this removal (default: true) |
| `RemoveFile(string fileName, bool ignoreCase)` | `Task` | Called on file remove. Parameters: `fileName`: The name of the file to remove. `ignoreCase`: Specify true is file name casing should be ignored (default: false) |
| `RemoveFileById(string fileId)` | `Task` | Removes the selected file with the specified identifier. Unknown identifiers are ignored. Parameters: `fileId`: The identifier supplied in Change event arguments. |
| `SetParametersAsync(ParameterView parameters)` | `Task` |  |
| `Upload()` | `Task` | Uploads this instance selected files. |

## Inherited Members

- 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, OnContextMenu, OnInitialized, OnMouseEnter, OnMouseLeave, RaiseContextMenu, RaiseMouseEnter, RaiseMouseLeave, Reference, Style, UICulture, UniqueID, Visible
- From ComponentBase: Assets, AssignedRenderMode, DispatchExceptionAsync, InvokeAsync, OnAfterRender, OnInitializedAsync, OnParametersSetAsync, RendererInfo, ShouldRender, StateHasChanged

