Repository navigation
FileMediaType
Viames Marino edited this page Apr 28, 2026
·
2 revisions
Pair\Http\FileMediaType is the shared MIME type and file-extension category registry used by upload handling and file input controls.
Returns all MIME types and extensions for a category.
Returns the first category matching a MIME type or file extension.
Returns every category matching a MIME type or file extension.
Returns whether a MIME type or extension belongs to a specific category. Use this for validation when a MIME type can belong to more than one category, such as text/plain.
audiobinarycsvdocumentflashimagepdfpresentationspreadsheetvideozip
use Pair\Http\FileMediaType;
$category = FileMediaType::category('application/pdf');
// 'pdf'
$acceptValues = FileMediaType::categoryTypes('image');
if (FileMediaType::matchesCategory('text/plain', 'csv')) {
// Accept CSV files detected by servers as text/plain.
}use Pair\Http\FileMediaType;
use Pair\Http\UploadedFile;
$upload = UploadedFile::fromGlobals('attachment');
$mediaType = $upload->mediaType();
if (!is_string($mediaType) || !FileMediaType::matchesCategory($mediaType, 'document')) {
throw new \RuntimeException('Attachment must be a document.');
}See also: UploadedFile, File.
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