UploadFormats
in package
FinalYes
Builds a readable list of accepted formats for the upload zone hint ("JPG, PNG, PDF").
A fixed hint text would claim formats and limits the field does not match, so the text is
built from the same configuration the server checks (allowedMimeTypes /
allowedExtensions of the uploader).
Table of Contents
Constants
- LABELS : array<string|int, mixed> = ['image/jpeg' => 'JPG', 'image/jpg' => 'JPG', '...
- MIME type mapped to its display name; synonyms (`image/jpg` and `image/jpeg`, `video/mov` and `video/quicktime`) share a name.
Methods
- label() : string
- Returns the formats in configuration order, without duplicates.
- mimeLabel() : string
Constants
LABELS
MIME type mapped to its display name; synonyms (`image/jpg` and `image/jpeg`, `video/mov` and `video/quicktime`) share a name.
private
array<string|int, mixed>
LABELS
= ['image/jpeg' => 'JPG', 'image/jpg' => 'JPG', 'image/pjpeg' => 'JPG', 'image/png' => 'PNG', 'image/gif' => 'GIF', 'image/webp' => 'WEBP', 'image/avif' => 'AVIF', 'image/svg+xml' => 'SVG', 'image/bmp' => 'BMP', 'image/tiff' => 'TIFF', 'video/mp4' => 'MP4', 'video/quicktime' => 'MOV', 'video/mov' => 'MOV', 'video/webm' => 'WEBM', 'application/pdf' => 'PDF', 'text/plain' => 'TXT', 'text/csv' => 'CSV', 'application/json' => 'JSON', 'application/xml' => 'XML', 'text/xml' => 'XML', 'application/zip' => 'ZIP', 'application/msword' => 'DOC', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document' => 'DOCX', 'application/vnd.ms-excel' => 'XLS', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' => 'XLSX', 'application/vnd.oasis.opendocument.text' => 'ODT', 'application/vnd.oasis.opendocument.spreadsheet' => 'ODS', 'application/rtf' => 'RTF']
Methods
label()
Returns the formats in configuration order, without duplicates.
public
static label(array<string|int, string> $allowedMimeTypes[, array<string|int, string> $allowedExtensions = [] ]) : string
Extensions (when given) are authoritative, as in the upload check; otherwise MIME types are used. An empty result means the field accepts any file.
Parameters
- $allowedMimeTypes : array<string|int, string>
- $allowedExtensions : array<string|int, string> = []
-
extensions without the dot (a leading dot is harmless)
Return values
stringmimeLabel()
private
static mimeLabel(string $mime) : string
Parameters
- $mime : string