当前位置: 首页>>代码示例>>PHP>>正文


PHP file::getMimeType方法代码示例

本文整理汇总了PHP中file::getMimeType方法的典型用法代码示例。如果您正苦于以下问题:PHP file::getMimeType方法的具体用法?PHP file::getMimeType怎么用?PHP file::getMimeType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在file的用法示例。


在下文中一共展示了file::getMimeType方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkFile

 public function checkFile($file, array $config)
 {
     if (!isset($config['params'])) {
         return "Undefined MIME types.";
     }
     $type = file::getMimeType($file, isset($config['mime_magic']) ? $config['mime_magic'] : null);
     $type = substr($type, 0, strrpos($type, ";"));
     $mimes = $config['params'];
     if (substr($mimes, 0, 1) == "!") {
         $mimes = trim(substr($mimes, 1));
         return in_array($type, explode(" ", $mimes)) ? "You can't upload such files." : true;
     }
     return !in_array($type, explode(" ", $mimes)) ? "You can't upload such files." : true;
 }
开发者ID:r-kitaev,项目名称:limb,代码行数:14,代码来源:type_mime.php

示例2: file

 /** Cache a file. The $type parameter might define the MIME type of the file
  * or path to magic file to autodetect the MIME type. If you skip $type
  * parameter the method will try with the default magic file. Autodetection
  * of MIME type requires Fileinfo PHP extension used in file::getMimeType()
  * @param string $file
  * @param string $type
  * @param integer $expire
  * @param array $headers */
 static function file($file, $type = null, $expire = null, array $headers = null)
 {
     $mtime = @filemtime($file);
     if ($mtime !== false) {
         self::checkMTime($mtime);
     }
     if ($type === null) {
         $magic = substr($type, 0, 1) == "/" || preg_match('/^[a-z]\\:/i', $type) ? $type : null;
         $type = file::getMimeType($file, $magic);
         if (!$type) {
             $type = null;
         }
     }
     self::content(@file_get_contents($file), $mtime, $type, $expire, $headers, false);
 }
开发者ID:ethan42411,项目名称:bludit-plugins,代码行数:23,代码来源:helper_httpCache.php

示例3: checkUploadedFileMime

 protected function checkUploadedFileMime($targetFile)
 {
     $targetFileResult = false;
     if (!$targetFile || !file_exists($targetFile)) {
         return false;
     }
     $targetFileResult = $targetFile;
     if ($target_imagesize = @getimagesize($targetFile)) {
         if (!function_exists('image_type_to_extension')) {
             return false;
         }
         $renameResult = FALSE;
         $targetFilePathInfo = pathinfo($targetFile);
         // Get the EXPECTED EXTENSION from this MIME
         $targetMimeInteger = $target_imagesize[2];
         $expectedExtension = @image_type_to_extension($targetMimeInteger);
         // get the existing MIME + MIME from the EXTENSION on this FILE ...
         $targetMimeString = $target_imagesize['mime'];
         $currentTargetMime = file::getMimeType($targetFile);
         if ($expectedExtension && $currentTargetMime != $targetMimeString) {
             // Ensure we use SHORTHAND JPG extensions ....
             if ($expectedExtension == ".jpeg" && $this->shortHandJpgExtensions) {
                 $expectedExtension = ".jpg";
             }
             // Rename the extension from whatever it was previously to a new extension ...
             $exptectedFileName = str_replace(".{$targetFilePathInfo['extension']}", $expectedExtension, $targetFile);
             $expectedFileResult = array('target' => basename($targetFile), 'destination' => basename($exptectedFileName));
             // Testing this code ...
             // echo "<pre style='font-size:10px;'>";
             // print_r($expectedFileResult);
             // echo "</pre>";
             // die();
             $renameResult = @rename($targetFile, $exptectedFileName);
         }
         if ($renameResult) {
             $targetFileResult = $exptectedFileName;
         }
     }
     return $targetFile;
 }
开发者ID:mikegrahamjones,项目名称:kcfinder,代码行数:40,代码来源:uploader.php


注:本文中的file::getMimeType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。