Skip to content

SanchayaPicker Form Field ​

The SanchayaPicker form component lets users pick existing files or upload new files directly inside any Filament Resource Form or Schema.

Add HasSanchayaFiles to the form's model to persist the selected attachments automatically. When enabled, the upload modal uses a chunked uploader that sends files in smaller requests.

php
use DP0\Sanchaya\Forms\Components\SanchayaPicker;

Single File Attachment

php
SanchayaPicker::make('avatar')
    ->label('Avatar Image')
    ->saveInGroup('avatar')
    ->allowedTypes(['image']);

Multiple Files Gallery

php
SanchayaPicker::make('gallery')
    ->label('Product Gallery')
    ->multiple()
    ->maxFiles(8)
    ->saveInGroup('gallery')
    ->allowedTypes(['image'])
    ->uploadMaxFileSize(5120) // 5 MB standard upload limit
    ->chunked() // Enable large-file uploads for this picker
    ->chunkedUploadMaxFileSize(102400); // 100 MB large-file limit

Module-specific directory

php
SanchayaPicker::make('product_images')
    ->directory('products');

Picker directories are relative to Sanchaya's configured storage base directory, not to the Laravel disk root. For example, with the default configuration, ->directory('products') generates paths like sanchaya/products/2026/10/{uuid}.jpg. The picker only browses, searches, selects, creates folders, copies, moves, and uploads files inside that namespace. File actions, bulk actions, and saved selections are checked against the directory and disk on the server; IDs outside the scope are not attached to the form's record. The standalone file manager remains global.

Directory values must be relative namespaces. Absolute paths and traversal segments such as ../ are rejected. A picker directory is independent from ->disk(): use disk() to choose the filesystem disk and directory() to isolate the namespace on that disk. Existing files outside that namespace are not moved or rewritten; use the standalone manager to manage them.

To enable chunked uploads only for a particular picker, override the global setting on the field:

php
SanchayaPicker::make('manual')
    ->chunked()
    ->chunkedUploadMaxFileSize(204800); // 200 MB, in KB

Use ->chunked(false) to use the standard Livewire uploader for a field when the global setting is enabled. The two upload controls are mutually exclusive. Standard uploads keep the Upload action disabled until the browser finishes transferring the selected file; the chunked mode assembles chunks before creating the final file record. With multiple(), chunked files are processed one at a time and the upload dialog closes only after the last file succeeds.

Removing a selected image with the X control updates the field selection. When you open Change again, the media library reflects the remaining selected files instead of reselecting the removed image. This behavior is available from v1.1.1.

Method Reference

MethodDescription
multiple(bool $condition = true)Enable multi-select mode.
maxFiles(int $count)Cap the maximum number of selectable files in multiple mode.
allowedTypes(array $types)Limit picker results by MIME group, such as ['image', 'video'].
saveInGroup(string $group)Polymorphic attachment group name for automatic relation sync.
uploadMaxFileSize(int $kb)Per-field standard upload size limit in KB.
chunked(bool $condition = true)Enable or disable large-file uploads for this picker. Off by default unless enabled globally in config.
chunkedUploadMaxFileSize(int $kb)Per-field large-file upload size limit in KB.
reorderable(bool $condition = true)Allow reordering selected files in multiple mode.
disk(string $disk)Set the initial disk shown by this picker.
uploadAcceptedFileTypes(array $types)Override accepted upload MIME types for this picker.
directory(?string $directory)Restrict this picker to a relative storage namespace.

Released under the MIT License.