mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-09-07 03:52:41 +00:00
Merge pull request #2741 from ADmad/2.5-mimetype
Added regex support to Validation::mimeType().
This commit is contained in:
commit
c325a93998
2 changed files with 14 additions and 3 deletions
|
@ -925,10 +925,10 @@ class Validation {
|
|||
}
|
||||
|
||||
/**
|
||||
* Checks the mime type of a file. Comparison is case sensitive.
|
||||
* Checks the mime type of a file.
|
||||
*
|
||||
* @param string|array $check
|
||||
* @param array $mimeTypes to check for
|
||||
* @param array|string $mimeTypes Array of mime types or regex pattern to check.
|
||||
* @return boolean Success
|
||||
* @throws CakeException when mime type can not be determined.
|
||||
*/
|
||||
|
@ -943,6 +943,14 @@ class Validation {
|
|||
if ($mime === false) {
|
||||
throw new CakeException(__d('cake_dev', 'Can not determine the mimetype.'));
|
||||
}
|
||||
|
||||
if (is_string($mimeTypes)) {
|
||||
return self::_check($mime, $mimeTypes);
|
||||
}
|
||||
|
||||
foreach ($mimeTypes as $key => $val) {
|
||||
$mimeTypes[$key] = strtolower($val);
|
||||
}
|
||||
return in_array($mime, $mimeTypes);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue