mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Tweaked Validation::extension()
This commit is contained in:
parent
ad5345887a
commit
76f93178a8
1 changed files with 3 additions and 4 deletions
|
@ -442,17 +442,16 @@ class Validation {
|
|||
* Check that value has a valid file extension.
|
||||
*
|
||||
* @param string|array $check Value to check
|
||||
* @param array $extensions file extensions to allow
|
||||
* @param array $extensions file extensions to allow. By default extensions are 'gif', 'jpeg', 'png', 'jpg'
|
||||
* @return boolean Success
|
||||
*/
|
||||
public static function extension($check, $extensions = array('gif', 'jpeg', 'png', 'jpg')) {
|
||||
if (is_array($check)) {
|
||||
return self::extension(array_shift($check), $extensions);
|
||||
}
|
||||
$pathSegments = explode('.', $check);
|
||||
$extension = strtolower(array_pop($pathSegments));
|
||||
$extension = strtolower(pathinfo($check, PATHINFO_EXTENSION));
|
||||
foreach ($extensions as $value) {
|
||||
if ($extension == strtolower($value)) {
|
||||
if ($extension === strtolower($value)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue