public static getExtensionsByMimeType ( string $mimeType, string $magicFile = null ) : array | ||
$mimeType | string | file MIME type. |
$magicFile | string | the path (or alias) of the file that contains all available MIME type information. If this is not set, the file specified by [[mimeMagicFile]] will be used. |
return | array | the extensions corresponding to the specified MIME type |
public static function getExtensionsByMimeType($mimeType, $magicFile = null)
{
$mimeTypes = static::loadMimeTypes($magicFile);
return array_keys($mimeTypes, mb_strtolower($mimeType, 'UTF-8'), true);
}
public function getMimeType() { $extensions = $result = []; foreach ($this->acceptedFilesType as $mimeType) { $extensions[] = BaseFileHelper::getExtensionsByMimeType($mimeType); } foreach ($extensions as $ext) { $result = \yii\helpers\ArrayHelper::merge($result, $ext); } return $result; }