FilePicker
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
| Name | Description | Required | Default |
|---|---|---|---|
startIn() | Directory the browser opens in, and the floor it cannot ascend above. | No | Current directory |
filesOnly() | Only files are selectable; directories stay navigable. | No | Files and directories |
directoriesOnly() | Only directories are selectable. | No | Files and directories |
extensions() | Restrict selectable files to these extensions (dot-less, case-insensitive). | No | All |
showHidden() | Show hidden (dot) entries when the browser opens. | No | Off |
pageSize() | Entries shown before the list pages around the cursor. | No | 10 |
filesOnly() and directoriesOnly() are mutually exclusive - the last one set
wins.
Keyboard
| Key | Action |
|---|---|
↑ / ↓ | Move the highlight |
→ | Descend into the highlighted directory |
← | Ascend to the parent (never above the start directory) |
| printable keys | Filter the current directory |
Tab | Toggle hidden entries |
Backspace | Delete a filter character, or ascend when the filter is empty |
Enter | Select the highlighted entry if selectable, otherwise descend into the directory |
Esc | Cancel |
Display modes
In all four display modes - Unicode or ASCII, colour on or off:
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |
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']);
| ANSI | No ANSI | |
| Unicode | ||
| ASCII |