當前位置: 首頁>>代碼示例>>PHP>>正文


PHP MIME_Type::_handleDetection方法代碼示例

本文整理匯總了PHP中MIME_Type::_handleDetection方法的典型用法代碼示例。如果您正苦於以下問題:PHP MIME_Type::_handleDetection方法的具體用法?PHP MIME_Type::_handleDetection怎麽用?PHP MIME_Type::_handleDetection使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在MIME_Type的用法示例。


在下文中一共展示了MIME_Type::_handleDetection方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: autoDetect

 /**
  * Autodetect a file's MIME-type
  *
  * This function may be called staticly.
  *
  * @internal Tries to use fileinfo extension at first. If that
  *  does not work, mime_magic is used. If this is also not available
  *  or does not succeed, "file" command is tried to be executed with
  *  System_Command. When that fails, too, then we use our in-built
  *  extension-to-mimetype-mapping list.
  *
  * @param string $file   Path to the file to get the type of
  * @param bool   $params Append MIME parameters if true
  *
  * @return string $file's MIME-type on success, PEAR_Error otherwise
  *
  * @since 1.0.0beta1
  * @static
  */
 function autoDetect($file, $params = false)
 {
     // Sanity checks
     if (!file_exists($file)) {
         return PEAR::raiseError("File \"{$file}\" doesn't exist");
     }
     if (!is_readable($file)) {
         return PEAR::raiseError("File \"{$file}\" is not readable");
     }
     // modifications by brusch for pimcore
     require_once 'MIME/Type/Extension.php';
     $mte = new MIME_Type_Extension();
     if ($type = $mte->getMIMEType($file)) {
         if (!PEAR::isError($type)) {
             return $type;
         }
     }
     if (function_exists('finfo_file')) {
         $finfo = finfo_open(FILEINFO_MIME);
         $type = finfo_file($finfo, $file);
         finfo_close($finfo);
         if ($type !== false && $type !== '') {
             return MIME_Type::_handleDetection($type, $params);
         }
     }
     if (function_exists('mime_content_type')) {
         $type = mime_content_type($file);
         if ($type !== false && $type !== '') {
             return MIME_Type::_handleDetection($type, $params);
         }
     }
     @(include_once 'System/Command.php');
     if (class_exists('System_Command')) {
         return MIME_Type::_handleDetection(MIME_Type::_fileAutoDetect($file), $params);
     }
 }
開發者ID:shanky0110,項目名稱:pimcore-custom,代碼行數:55,代碼來源:Type.php

示例2: _autoDetect

 /**
  * Autodetect a file's MIME-type
  *
  * @param string $file   Path to the file to get the type of
  * @param bool   $params Append MIME parameters if true
  *
  * @return string $file's MIME-type on success, PEAR_Error otherwise
  *
  * @since 1.3.0
  *
  * @internal Tries to use fileinfo extension at first. If that
  *  does not work, mime_magic is used. If this is also not available
  *  or does not succeed, "file" command is tried to be executed with
  *  System_Command. When that fails, too, then we use our in-built
  *  extension-to-mimetype-mapping list.
  */
 function _autoDetect($file, $params = false)
 {
     // Sanity checks
     if (!file_exists($file)) {
         return PEAR::raiseError("File \"{$file}\" doesn't exist");
     }
     if (!is_readable($file)) {
         return PEAR::raiseError("File \"{$file}\" is not readable");
     }
     if ($this->useFinfo && function_exists('finfo_file')) {
         $finfo = finfo_open(FILEINFO_MIME, $this->magicFile);
         if ($finfo) {
             $type = finfo_file($finfo, $file);
             finfo_close($finfo);
             if ($type !== false && $type !== '') {
                 return MIME_Type::_handleDetection($type, $params);
             }
         }
     }
     if ($this->useMimeContentType && function_exists('mime_content_type')) {
         $type = mime_content_type($file);
         if ($type !== false && $type !== '') {
             return MIME_Type::_handleDetection($type, $params);
         }
     }
     if ($this->useFileCmd) {
         @(include_once 'System/Command.php');
         if (class_exists('System_Command')) {
             $type = MIME_Type::_fileAutoDetect($file);
             if ($type !== false && $type !== '') {
                 return MIME_Type::_handleDetection($type, $params);
             }
         }
     }
     if ($this->useExtension) {
         include_once 'MIME/Type/Extension.php';
         $mte = new MIME_Type_Extension();
         return $mte->getMIMEType($file);
     }
     return PEAR::raiseError("Sorry, couldn't determine file type.");
 }
開發者ID:MusicalAPP,項目名稱:gfk-api-spotify-itunes,代碼行數:57,代碼來源:Type.php

示例3: autoDetect

 /**
  * Autodetect a file's MIME-type
  *
  * This function may be called staticly.
  *
  * @internal Tries to use fileinfo extension at first. If that
  *  does not work, mime_magic is used. If this is also not available
  *  or does not succeed, "file" command is tried.
  *
  * @param string $file   Path to the file to get the type of
  * @param bool   $params Append MIME parameters if true
  *
  * @return string $file's MIME-type on success, PEAR_Error otherwise
  *
  * @since 1.0.0beta1
  * @static
  */
 function autoDetect($file, $params = false)
 {
     // Sanity checks
     if (!file_exists($file)) {
         return PEAR::raiseError("File \"{$file}\" doesn't exist");
     }
     if (!is_readable($file)) {
         return PEAR::raiseError("File \"{$file}\" is not readable");
     }
     if (function_exists('finfo_file')) {
         $finfo = finfo_open(FILEINFO_MIME);
         $type = finfo_file($finfo, $file);
         finfo_close($finfo);
         if ($type !== false && $type !== '') {
             return MIME_Type::_handleDetection($type, $params);
         }
     }
     if (function_exists('mime_content_type')) {
         $type = mime_content_type($file);
         if ($type !== false && $type !== '') {
             return MIME_Type::_handleDetection($type, $params);
         }
     }
     @(include_once 'System/Command.php');
     if (class_exists('System_Command')) {
         return MIME_Type::_handleDetection(MIME_Type::_fileAutoDetect($file), $params);
     }
     return PEAR::raiseError("Sorry, can't autodetect; you need the fileinfo or" . " mime_magic extension" . " or System_Command and 'file' installed" . " to use this function.");
 }
開發者ID:quangbt2005,項目名稱:vhost-kis,代碼行數:46,代碼來源:Type.php


注:本文中的MIME_Type::_handleDetection方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。