hasMimeType.php
Table of Contents
Functions
- hasMimeType() : bool
- Checks whether a file's MIME type matches one of the given MIME types.
Functions
hasMimeType()
Checks whether a file's MIME type matches one of the given MIME types.
hasMimeType(string $filePath, string|array<string|int, string> $mimeTypes) : bool
The file's MIME type is detected with finfo and compared to each entry of
$mimeTypes using a substring match (via str_contains()), so a partial
type such as application/zip matches a detected application/zip; charset=binary.
Parameters
- $filePath : string
-
Path to the file.
- $mimeTypes : string|array<string|int, string>
-
A single MIME type, or a list of MIME types (or fragments) to match against.
Tags
Return values
bool —True if the file exists and its detected MIME type contains one of $mimeTypes.