# File Upload
> A drop zone that opens the file picker and lists the files you picked.
Source: https://native.shellui.dev/docs/components/form/file-upload
## Installation
```bash
shellui-native add file-upload
```
**Platforms:** MAUI · Avalonia. Also installs `icon`.
## Usage
### Basic
**MAUI**
```xml
```
**Avalonia**
```xml
```
[Live preview](https://native.shellui.dev/preview/index.html?c=file-upload-basic)
Tapping the zone opens the platform file picker. The picked files are listed underneath, each with a × to remove it. Without `Multiple`, a new pick replaces the file.
### Reading the files
`FilesChanged` passes the current list. Open each file as a stream:
**MAUI**
```csharp
private async void OnFilesChanged(object? sender, IReadOnlyList files)
{
foreach (var file in files)
{
await using var stream = await file.OpenReadAsync();
// upload or read the stream
}
}
```
**Avalonia**
```csharp
private async void OnFilesChanged(object? sender, IReadOnlyList files)
{
foreach (var file in files)
{
await using var stream = await file.OpenReadAsync();
// upload or read the stream
}
}
```
### Limiting the file types
`FileTypes` takes the platform's own picker type, so set it in code:
**MAUI**
```csharp
Upload.FileTypes = FilePickerFileType.Images;
```
**Avalonia**
```csharp
Upload.FileTypes = new[] { FilePickerFileTypes.ImageAll };
```
## MAUI and Avalonia
- Files are `FileResult` on MAUI and `IStorageFile` on Avalonia.
- Dropping files on the zone works on Windows only on MAUI, and wherever Avalonia supports drag and drop on Avalonia.
- On Avalonia the zone is a tab stop: Enter or Space opens the picker.
## API
| Property | Type | Default | Description |
|---|---|---|---|
| `Text` | `string` | `"Drag and drop or click here to upload files"` | Prompt shown in the drop zone. |
| `Multiple` | `bool` | `false` | More than one file can be picked; new picks are added to the list. |
| `MaxFiles` | `int` | `0` | The most files the list holds when `Multiple` is on; `0` for no limit. |
| `FileTypes` | `FilePickerFileType` (MAUI) · `IReadOnlyList?` (Avalonia) | `null` | Which files the picker offers; `null` offers every file. Set it in code. |
| `ShowFiles` | `bool` | `true` | Lists the picked files under the drop zone. |
| Event | Arguments | Description |
|---|---|---|
| `FilesChanged` | `IReadOnlyList` (MAUI) · `IReadOnlyList` (Avalonia) | The list of files changed; passes the current list. |
| Method | Description |
|---|---|
| `PickAsync()` | Opens the platform file picker and adds what was picked. |
| `Add(IEnumerable files)` | Adds files as a pick or a drop would. |
| `Remove(FileResult file)` | Removes one file from the list. |
| `Clear()` | Removes every file. |