Repository navigation
File
Viames Marino edited this page Apr 26, 2026
·
3 revisions
Pair\Html\FormControls\File renders file upload inputs and uses the shared Pair\Http\FileMediaType MIME-category registry.
accept(string|array $mimeType): selfacceptCategory(string $mimeCategory): selfacceptCategories(array $mimeCategories): selfcapture(?string $cameraFacingMode = null): self-
mimeCategory(string $mimeType): ?string(static) render(): string
Built-in categories from Pair\Http\FileMediaType:
audiobinarycsvdocumentflashimagepdfpresentationspreadsheetvideozip
-
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.
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'The accept attribute helps UX but does not replace server-side upload validation.
See also: FormControl, UploadedFile, FileMediaType, Image.
Home · Setup · Configuration
Build with Pair 4
- Generator
- Controllers and responses
- Read models
- ActiveRecord and queries
- Forms and validation
- PairUI.js and HTML fragments
APIs and authentication
- API guide and CRUD
- Middleware and rate limits
- Users, sessions, and ACL
- Passkeys and social login
- Native mobile setup
Integrate and operate
- Integrations
- Runtime extensions and adapter keys
- Cache and cache stores
- Logs and observability
- PWA and push
- Packages and distribution
- Upgrade to v4