1. Reference
  2. Media

<file-picker>

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

Media Uses photo_libraryUses camera

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

file-picker.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>
The snippet drawn by Hype Apps on a phone, in light mode The snippet drawn by Hype Apps on a phone, in dark mode
This snippet as Hype Apps draws it on a phone. It follows this page's light or dark theme.

Attributes

NameWhat it doesDefault
camera-facing Camera direction when source=camera
back, front
back
crop Crop after pick: true, false, circle, 1:1, 16:9, etc.
string
extensions Comma-separated file extensions for type=file
string
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).
boolean
true
max-height Max image height for downscaling
number
max-width Max image width for downscaling
number
multiple Allow multi-select
boolean
false
name Variable name for selected path
string
quality JPEG compression quality 0-100
number
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

NameWhat 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.

This page is also Markdown, and all of HAM is in llms.txt.