# <file-picker>

Opens the device's photo, video or file picker (or the camera) and puts the chosen file in a variable.

Category: Media. Uses photo_library, camera.

This tag needs a photo library or a camera, so try it on your phone.

```ham
<column style="gap-12 w-full">
    <file-picker name="photo"
                 source="both"
                 crop="1:1">
        <button variant="filled"
                icon="add_a_photo">Add a photo</button>
    </file-picker>
    <text style="muted text-sm">Square photos look best on your profile.</text>
</column>
```

How Hype Apps draws it on a phone: [light](https://hypeapps.dev/img/tags/file-picker-light.webp), [dark](https://hypeapps.dev/img/tags/file-picker-dark.webp).

## Attributes

| Name | What it does | Default |
|---|---|---|
| `camera-facing` | Camera direction when source=camera (back, front) | `back` |
| `crop` | Crop after pick: true, false, circle, 1:1, 16:9, etc. |  |
| `extensions` | Comma-separated file extensions for type=file |  |
| `keep` | Move the picked file into the app's own storage and publish a media: reference that survives cache clears, updates and reinstalls. false keeps the OS cache path (an upload-only field). | `true` |
| `max-height` | Max image height for downscaling |  |
| `max-width` | Max image width for downscaling |  |
| `multiple` | Allow multi-select | `false` |
| `name` | Variable name for selected path |  |
| `quality` | JPEG compression quality 0-100 | `80` |
| `source` | Where an image or video comes from: the library, the system camera, or a sheet that asks (both). (gallery, camera, both) | `gallery` |
| `type` | Content type (image, video, media, file) | `image` |

## Readings

| Name | What it does |
|---|---|
| `count` | How many files the last pick chose (more than 1 only with multiple=). |
| `filename` | The picked file's name. |
| `size` | The picked file's size in bytes. |
| `type` | The picked file's MIME type. |
| `value` | The picked file's path; empty before a pick. |

Any tag also takes gestures: `@on.tap`, `@on.longpress`, `@on.doubletap` and `@on.swipeleft` (and right, up and down). `@click` runs on a tap too.

## Related tags

- [`<column>`](https://hypeapps.dev/docs/reference/column.md): Stacks its children top to bottom, with a gap between them and an alignment across.
- [`<button>`](https://hypeapps.dev/docs/reference/button.md): A tappable button that runs an action: a fetch, a navigation or a statement.
- [`<text>`](https://hypeapps.dev/docs/reference/text.md): A run of text; with @text it shows an expression that updates as its variables change.
- [`<audio>`](https://hypeapps.dev/docs/reference/audio.md): A compact audio player bar with play, a progress track and the track's title and artist.
- [`<camera>`](https://hypeapps.dev/docs/reference/camera.md): A live camera viewfinder with a shutter; the photo's path goes into a variable.
- [`<canvas>`](https://hypeapps.dev/docs/reference/canvas.md): A drawing surface for finger or stylus, with a pen, eraser and color toolbar; it saves as a PNG.
- [`<img>`](https://hypeapps.dev/docs/reference/img.md): Shows a picture from a URL or the app's files, sized and cropped by its style.
- [`<layer>`](https://hypeapps.dev/docs/reference/layer.md): Declares one layer of a drawing surface: a locked picture to trace over, and a layer to paint on.

All tags: https://hypeapps.dev/docs/reference.md · The full reference: https://hypeapps.dev/llms.txt
