mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-01 00:02:21 +09:00
Storage::getContentType() 메소드를 MIME 클래스로 이동함
This commit is contained in:
parent
9163bc24e9
commit
805a7324cc
4 changed files with 36 additions and 36 deletions
|
|
@ -7,6 +7,38 @@ namespace Rhymix\Framework;
|
|||
*/
|
||||
class MIME
|
||||
{
|
||||
/**
|
||||
* Get the MIME type of a file, detected by its content.
|
||||
*
|
||||
* This method returns the MIME type of a file, or false on error.
|
||||
*
|
||||
* @param string $filename
|
||||
* @return array|false
|
||||
*/
|
||||
public static function getContentType($filename)
|
||||
{
|
||||
$filename = rtrim($filename, '/\\');
|
||||
if (Storage::exists($filename) && @is_file($filename) && @is_readable($filename))
|
||||
{
|
||||
if (function_exists('mime_content_type'))
|
||||
{
|
||||
return @mime_content_type($filename) ?: false;
|
||||
}
|
||||
elseif (($image = @getimagesize($filename)) && $image['mime'])
|
||||
{
|
||||
return $image['mime'];
|
||||
}
|
||||
else
|
||||
{
|
||||
return self::getTypeByFilename($filename);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the MIME type for the given extension.
|
||||
*
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue