---
title: "FileUpload-Komponente — zenit Zig UI"
description: "Dateiauswahl und Ablagebereich. Browse, Ablagezone, Dateiliste und App-Callback bilden einen testbaren Zustand."
url: https://zenit.z.express/de/components/upload
language: de
alternate_en: https://zenit.z.express/components/upload.md
alternate_zh: https://zenit.z.express/zh/components/upload.md
alternate_es: https://zenit.z.express/es/components/upload.md
alternate_ja: https://zenit.z.express/ja/components/upload.md
alternate_ko: https://zenit.z.express/ko/components/upload.md
alternate_fr: https://zenit.z.express/fr/components/upload.md
project: zenit v0.1.0-alpha (Zig 0.15.2, macOS)
source: https://github.com/version-next/zenit
---

# FileUpload

`ui.widgets.FileUpload`

Dateiauswahl und Ablagebereich.

[Video](https://zenit.z.express/media/stories/upload.mp4?v=30b9aa65f9)

**BEHAVIOR CONTRACT**

Browse, Ablagezone, Dateiliste und App-Callback bilden einen testbaren Zustand.

**RECORDED INTERACTION**

Der Harness klickt Browse…; die Story trägt einen deterministischen Dateipfad ein.

`examples/storybook/stories.zig:3069`

```zig
pub fn buildFileUpload(scope: *ui.Scope, cx: *ui.Cx) anyerror!*ui.Node {
    const a = cx.allocator;
    const c = try col(cx, 12);
    const story = try cx.bindState(FileUploadStory, .{ .state = undefined });
    const fu = try ui.widgets.FileUpload(.{
        .width = 380,
        .on_browse = cx.on(FileUploadStory, story, FileUploadStory.browse),
    }, scope, cx);
    story.state = fu.state;
    fu.wrapper.meta.ownership.meta.test_id = "story.upload.wrapper";
    // 拖放 drop zone：e2e 用 dragAt 往这块矩形里注入 entered/dropped
    fu.state.drop_zone.meta.ownership.meta.test_id = "story.upload.dropzone";
    try c.appendChild(a, fu.wrapper);
    return c;
}
```

[Quellcode auf GitHub ansehenexamples/storybook/stories.zig:3069](https://github.com/version-next/zenit/blob/HEAD/examples/storybook/stories.zig#L3069)

Der unveränderte Quellcode der Story aus dem Storybook (zenit 5f9add5+wip 2026-09-30). `W` steht für `ui.widgets`; `col` / `row` / `label` sind kleine Layout-Helfer des Storybooks.

### FileUploadProps

`ui.widgets.FileUpload`

[src/ui/components/file\_upload/mod.zig:26](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/file_upload/mod.zig#L26)

```zig
fn mountFileUpload(props: FileUploadProps, scope: *Scope, cx: *Cx) !FileUploadMount
```

| Feld | Typ | Standard | Beschreibung |
| --- | --- | --- | --- |
| `width` | `f32` | `360` | — |
| `max_files` | `usize` | `8` | — |
| `hint` | `[]const u8` | `"Click Browse to add files"` | — |
| `on_browse` | `?core.HandlerRef` | `null` | Browse 按钮回调（宿主调起对话框后用 state.addFile 回填）。 null = 默认原生 NSOpenPanel（cx.openFilePanel）。 |
| `on_change` | `?core.HandlerRef` | `null` | 文件列表变化回调 |

### FileUploadMount

`ui.widgets.FileUpload`

[src/ui/components/file\_upload/mod.zig:199](https://github.com/version-next/zenit/blob/HEAD/src/ui/components/file_upload/mod.zig#L199)

| Feld | Typ | Standard | Beschreibung |
| --- | --- | --- | --- |
| `wrapper` | `*Node` | — | — |
| `state` | `*FileUploadState` | — | — |
