type validation adjusted

This commit is contained in:
Mark
2014-06-14 12:42:12 +04:00
parent 604b464ead
commit 42643e3747
2 changed files with 85 additions and 4 deletions

View File

@@ -161,6 +161,26 @@ class BaseFileHelper
return null;
}
/**
* Determines the extensions by given mime-type.
* This method will use a local map between extension names and MIME types.
* @param string $mimeType file mime-type.
* @param string $magicFile the path of the file that contains all available MIME type information.
* If this is not set, the default file aliased by `@yii/util/mimeTypes.php` will be used.
* @return array.
*/
public static function getExtensionsByMimeType($mimeType, $magicFile = null)
{
static $mimeTypes = [];
if (!count($mimeTypes)) {
$magicFile = __DIR__ . '/mimeTypes.php';
$mimeTypes = require($magicFile);
}
return array_keys($mimeTypes, mb_strtolower($mimeType, 'utf-8'));
}
/**
* Copies a whole directory as another one.
* The files and sub-directories will also be copied over.