[**Documentation**](../../../../README)

***

[Documentation](../../../../README) / [@zerotal/flow](../../README) / [index](../README) / FileUploads

# Function: FileUploads()

> **FileUploads**\<`TBase`\>(`Base`): \{(...`args`): `WithUploads`; `prototype`: `WithUploads`\<`any`\>; \} & `TBase`

Defined in: [flow/src/uploads/FileUploads.ts:72](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/flow/src/uploads/FileUploads.ts#L72)

Component mixin that adds server-side file-upload management — flow's
equivalent of Livewire's `WithFileUploads` trait.

## Type Parameters

### TBase

`TBase` *extends* `AbstractComponentCtor`

The (abstract) Component constructor being extended.

## Parameters

### Base

`TBase`

The component class to mix into.

## Returns

\{(...`args`): `WithUploads`; `prototype`: `WithUploads`\<`any`\>; \} & `TBase`

A subclass of `Base` with upload-management actions.

## Remarks

Uploading itself needs no mixin: a `<FileUpload>` / file `<input flow:model>`
POSTs bytes to `/__flow/upload` (over HTTP, with live progress) and then
`$set`s a signed reference that the base Component resolves into a
[TemporaryUploadedFile](../classes/TemporaryUploadedFile). This mixin adds the ergonomic action for managing
those pending uploads — chiefly WithUploads.removeUpload \| removeUpload,
for clearing a chosen file before it's stored — without bloating the base class.
Bind a single property to accept one file, or an array (with `multiple` on
`<FileUpload>`) to accept several.

## Example

```tsx
class Avatar extends ComponentWith(FileUploads) {
  @expose photo: TemporaryUploadedFile | null = null;
  @expose path = "";

  @expose async save() {
    this.path = (await this.photo?.store("avatars")) ?? this.path;
    this.photo = null;
  }

  async render() {
    return (
      <div>
        <FileUpload bind={this.photo} accept="image/*" />
        <button onClick={() => this.removeUpload("photo")}>Remove</button>
        <button onClick={this.save}>Save</button>
      </div>
    );
  }
}
```
