File - viames/pair GitHub Wiki
Pair framework: File
Pair\Html\FormControls\File renders file upload inputs and uses the shared Pair\Http\FileMediaType MIME-category registry.
Methods
accept(string|array $mimeType): selfacceptCategory(string $mimeCategory): selfacceptCategories(array $mimeCategories): selfcapture(?string $cameraFacingMode = null): selfmimeCategory(string $mimeType): ?string(static)render(): string
MIME categories
Built-in categories from Pair\Http\FileMediaType:
audiobinarycsvdocumentflashimagepdfpresentationspreadsheetvideozip
Behavior
accept(...)is cumulative: multiple calls append entries separated by commas.acceptCategory(...)silently ignores unknown categories.capture(...)sets thecaptureattribute for mobile camera/source hints.mimeCategory(...)returns the first matching category for a MIME string or extension, otherwisenull.
Examples
Allow images and PDFs:
$attachment = (new \Pair\Html\FormControls\File('attachment'))
->acceptCategory('image')
->acceptCategory('pdf')
->required();
Explicit MIME list + camera hint:
$avatar = (new \Pair\Html\FormControls\File('avatar'))
->accept(['image/png', 'image/jpeg'])
->capture('user');
Resolve category from MIME string:
$category = \Pair\Html\FormControls\File::mimeCategory('application/pdf');
// 'pdf'
Notes
The accept attribute helps UX but does not replace server-side upload validation.
See also: FormControl, UploadedFile, FileMediaType, Image.