Skip to main content

FilePicker

FilePicker widgetFilePicker widget

Browse the filesystem for a single path. It collects the chosen path (a string).

$p->filePicker('list', 'Price list')
->startIn(getcwd()) // Directory to open in (and the floor for ←).
->filesOnly() // Only files are selectable; directories stay navigable.
->extensions(['csv']) // Limit selectable files to these extensions.
->showHidden(); // Show hidden (dot) entries when the browser opens.

Runnable scripts: playground/02-widgets/filepicker.php and filepicker-multiple.php.

Options

NameDescriptionRequiredDefault
startIn()Directory the browser opens in, and the floor it cannot ascend above.NoCurrent directory
filesOnly()Only files are selectable; directories stay navigable.NoFiles and directories
directoriesOnly()Only directories are selectable.NoFiles and directories
extensions()Restrict selectable files to these extensions (dot-less, case-insensitive).NoAll
showHidden()Show hidden (dot) entries when the browser opens.NoOff
pageSize()Entries shown before the list pages around the cursor.No10

filesOnly() and directoriesOnly() are mutually exclusive - the last one set wins.

Keyboard

KeyAction
/ Move the highlight
Descend into the highlighted directory
Ascend to the parent (never above the start directory)
printable keysFilter the current directory
TabToggle hidden entries
BackspaceDelete a filter character, or ascend when the filter is empty
EnterSelect the highlighted entry if selectable, otherwise descend into the directory
EscCancel

Display modes

In all four display modes - Unicode or ASCII, colour on or off:

ANSINo ANSI
UnicodeFile picker: Unicode + ANSIFile picker: Unicode + ANSIFile picker: Unicode + No ANSIFile picker: Unicode + No ANSI
ASCIIFile picker: ASCII + ANSIFile picker: ASCII + ANSIFile picker: ASCII + No ANSIFile picker: ASCII + No ANSI

Multiple selection

Add ->multiple() to accumulate several paths (a list<string>) instead of one: Space toggles the highlighted entry and selections accumulate as you browse between directories, and Enter accepts them all.

$p->filePicker('lists', 'Price lists')
->multiple()
->startIn(getcwd())
->extensions(['csv']);

FilePicker widget in multiple modeFilePicker widget in multiple mode

ANSINo ANSI
UnicodeFile picker (multiple): Unicode + ANSIFile picker (multiple): Unicode + ANSIFile picker (multiple): Unicode + No ANSIFile picker (multiple): Unicode + No ANSI
ASCIIFile picker (multiple): ASCII + ANSIFile picker (multiple): ASCII + ANSIFile picker (multiple): ASCII + No ANSIFile picker (multiple): ASCII + No ANSI