44 lines
1016 B
PHP
44 lines
1016 B
PHP
<?php
|
||
/**
|
||
* Created by PhpStorm.
|
||
* User: liujin834
|
||
* Date: 14/12/26
|
||
* Time: 下午3:52
|
||
*/
|
||
|
||
namespace Westdc\File;
|
||
|
||
use Zend\ServiceManager\ServiceManager;
|
||
use Zend\ServiceManager\ServiceManagerAwareInterface;
|
||
|
||
class File implements ServiceManagerAwareInterface{
|
||
|
||
protected $serviceManager;
|
||
|
||
public function setServiceManager(ServiceManager $serviceManager)
|
||
{
|
||
$this->serviceManager = $serviceManager;
|
||
|
||
return $this;
|
||
}
|
||
|
||
//获取文件扩展名
|
||
public function getFileTextExt($file_name)
|
||
{
|
||
$temp_arr = explode(".", $file_name);
|
||
$file_ext = array_pop($temp_arr);
|
||
$file_ext = trim($file_ext);
|
||
$file_ext = strtolower($file_ext);
|
||
return $file_ext;
|
||
}
|
||
|
||
//获取文件Mime,通过finfo扩展
|
||
public function getFileMime($file_name)
|
||
{
|
||
$finfo = finfo_open(FILEINFO_MIME_TYPE);
|
||
$filetype = finfo_file($finfo, $file_name) ; //文件mime类型
|
||
finfo_close($finfo);
|
||
return $filetype;
|
||
}
|
||
|
||
}
|