Catch error when trying to upload empty or invalid avatar

This commit is contained in:
Manfred Hoffmann
2021-04-20 07:42:58 +02:00
committed by GitHub
parent 6f8f5aff33
commit ae39544e10
38 changed files with 100 additions and 2 deletions

View File

@@ -136,4 +136,24 @@ class AvatarFileModel extends Base
{
return implode(DIRECTORY_SEPARATOR, array(self::PATH_PREFIX, $user_id, hash('sha1', $filename.time())));
}
/**
* Check if a filename is an image (file types that can be shown as avatar)
*
* @access public
* @param string $filename Filename
* @return bool
*/
public function isAvatarImage($filename)
{
switch (get_file_extension($filename)) {
case 'jpeg':
case 'jpg':
case 'png':
case 'gif':
return true;
}
return false;
}
}