本文整理匯總了PHP中MailSo\Base\Utils::GetFileExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP Utils::GetFileExtension方法的具體用法?PHP Utils::GetFileExtension怎麽用?PHP Utils::GetFileExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MailSo\Base\Utils
的用法示例。
在下文中一共展示了Utils::GetFileExtension方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: clearFileName
/**
* @param string $sFileName
* @param string $sContentType
* @param string $sMimeIndex = ''
*
* @return string
*/
public function clearFileName($sFileName, $sContentType, $sMimeIndex = '')
{
$sFileName = 0 === strlen($sFileName) ? preg_replace('/[^a-zA-Z0-9]/', '.', (empty($sMimeIndex) ? '' : $sMimeIndex . '.') . $sContentType) : $sFileName;
$sClearedFileName = preg_replace('/[\\s]+/', ' ', preg_replace('/[\\.]+/', '.', $sFileName));
$sExt = \MailSo\Base\Utils::GetFileExtension($sClearedFileName);
$iSize = 100;
if ($iSize < strlen($sClearedFileName) - strlen($sExt)) {
$sClearedFileName = substr($sClearedFileName, 0, $iSize) . (empty($sExt) ? '' : '.' . $sExt);
}
return \MailSo\Base\Utils::ClearFileName(\MailSo\Base\Utils::Utf8Clear($sClearedFileName));
}
示例2: ContentTypeType
/**
* @param string $sContentType
* @param string $sFileName
*
* @return string
*/
public static function ContentTypeType($sContentType, $sFileName)
{
$sResult = '';
$sContentType = \strtolower($sContentType);
if (0 === \strpos($sContentType, 'image/')) {
$sResult = 'image';
} else {
switch ($sContentType) {
case 'application/zip':
case 'application/x-7z-compressed':
case 'application/x-rar-compressed':
case 'application/x-msdownload':
case 'application/vnd.ms-cab-compressed':
case 'application/x-gzip':
case 'application/x-bzip':
case 'application/x-bzip2':
case 'application/x-debian-package':
$sResult = 'archive';
break;
case 'application/msword':
case 'application/rtf':
case 'application/vnd.ms-excel':
case 'application/vnd.ms-powerpoint':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.template':
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
case 'application/vnd.oasis.opendocument.text':
case 'application/vnd.oasis.opendocument.spreadsheet':
$sResult = 'doc';
break;
case 'application/pdf':
case 'application/x-pdf':
$sResult = 'pdf';
break;
}
if ('' === $sResult) {
switch (\strtolower(\MailSo\Base\Utils::GetFileExtension($sFileName))) {
case 'zip':
case '7z':
case 'rar':
$sResult = 'archive';
break;
}
}
}
return $sResult;
}
示例3: isFileHasThumbnail
/**
* @param string $sFileName
*
* @return bool
*/
public function isFileHasThumbnail($sFileName)
{
static $aCache = array();
$sExt = \MailSo\Base\Utils::GetFileExtension($sFileName);
if (isset($aCache[$sExt])) {
return $aCache[$sExt];
}
$bResult = \function_exists('gd_info');
if ($bResult) {
$bResult = false;
switch ($sExt) {
case 'png':
$bResult = \function_exists('imagecreatefrompng');
break;
case 'gif':
$bResult = \function_exists('imagecreatefromgif');
break;
case 'jpg':
case 'jpeg':
$bResult = \function_exists('imagecreatefromjpeg');
break;
}
}
$aCache[$sExt] = $bResult;
return $bResult;
}