PickFiles
Opens a file picker dialog when the control is activated.
Equivalent to FilePicker.pick_files, but performed by the
client inside the user's gesture, which is the only time a browser opens a
file picker. This is what makes file picking work in a web app on iOS.
Unlike pick_files(), the selection is not returned to the caller - it
arrives at FilePicker.on_result. The files stay associated with
file_picker, so they can be passed straight to
FilePicker.upload.
picker = ft.FilePicker(on_result=handle_result)
page.services.append(picker)
ft.Button("Upload", action=ft.PickFiles(picker, allow_multiple=True))
Inherits: ClientAction
Properties
allow_multiple- Allow the selection of multiple files at once.allowed_extensions- The allowed file extensions.cancel_upload_on_window_blur- Web-only.compression_quality- Image compression quality from0to100.dialog_title- The title of the dialog window.file_picker- TheFilePickerthat opens the dialog and reports the result through itson_resultevent.file_type- The file types allowed to be selected.initial_directory- The initial directory where the dialog should open.with_data- Read selected file contents intoFilePickerFile.bytes.
Properties
allow_multipleclass-attributeinstance-attribute
allow_multiple: bool = action_field(False)Allow the selection of multiple files at once.
allowed_extensionsclass-attributeinstance-attribute
allowed_extensions: list[str] | None = action_field(None)The allowed file extensions. Has effect only if file_type is
FilePickerFileType.CUSTOM.
cancel_upload_on_window_blurclass-attributeinstance-attribute
cancel_upload_on_window_blur: bool = action_field(True)Web-only. Whether to treat browser window blur as a cancelled selection.
compression_qualityclass-attributeinstance-attribute
compression_quality: int = action_field(0)Image compression quality from 0 to 100. 0 disables compression.
dialog_titleclass-attributeinstance-attribute
dialog_title: str | None = action_field(None)The title of the dialog window.
file_pickerclass-attributeinstance-attribute
file_picker: FilePicker = action_field()The FilePicker that opens the dialog and reports the result
through its on_result event.
file_typeclass-attributeinstance-attribute
file_type: FilePickerFileType | None = action_field(None)The file types allowed to be selected.
initial_directoryclass-attributeinstance-attribute
initial_directory: str | None = action_field(None)The initial directory where the dialog should open.
with_dataclass-attributeinstance-attribute
with_data: bool = action_field(False)Read selected file contents into FilePickerFile.bytes.