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


PHP finfo_close函数代码示例

本文整理汇总了PHP中finfo_close函数的典型用法代码示例。如果您正苦于以下问题:PHP finfo_close函数的具体用法?PHP finfo_close怎么用?PHP finfo_close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: download

 public function download()
 {
     if (!$this->file_path) {
         $file = explode("/", $this->file_path);
         throw new Exception("Error finding file {$file[4]}.");
     } else {
         $finfo = finfo_open();
         $this->fileinfo = finfo_file($finfo, $this->file_path, FILEINFO_MIME);
         finfo_close($finfo);
         try {
             $this->sendHeaders();
         } catch (exception $e) {
             throw new Exception($e->getMessage());
         }
     }
     flush();
     $this->_oldMaxExecTime = ini_get('max_execution_time');
     ini_set('max_execution_time', 0);
     $this->delay = 256 / $this->downloadRate * 1000;
     $file = fopen($this->file_path, "rb");
     while (!feof($file)) {
         echo fread($file, $this->downloadRate);
         //((($this->downloadRate)*1024)/$this->_tickRate)
         flush();
         usleep($this->delay);
     }
     fclose($file);
     ini_set('max_execution_time', $this->_oldMaxExecTime);
     return true;
     // file downloaded.
 }
开发者ID:jhersonn20,项目名称:myportal,代码行数:31,代码来源:Downloader.php

示例2: registerStaticDirectory

 /**
  * Registers all the files of a static directory as resources.
  *
  * @param string 	$path 		The absolute path on the server which contains the files
  * @param string 	$prefix 	A prefix to add to the name of the static files
  * @return Route
  */
 public function registerStaticDirectory($path)
 {
     $path = rtrim($path, '/\\');
     return $this->register('/{file}', 'get')->pattern('file', '([^\\.]{2,}.*|.)')->name($path)->before(function (&$file, &$isRightResource) use($path) {
         $file = $path . DIRECTORY_SEPARATOR . str_replace('/', DIRECTORY_SEPARATOR, $file);
         if (!file_exists($file) || is_dir($file)) {
             $isRightResource = false;
             return;
         }
     })->before(function ($file, $etagResponseFilter) {
         $etagResponseFilter->setEtag(md5($file . filemtime($file)));
     })->handler(function ($file, $response, $elapsedTime) {
         if (!extension_loaded('fileinfo')) {
             throw new \LogicException('The "fileinfo" extension must be activated');
         }
         $finfo = finfo_open(FILEINFO_MIME);
         $mime = finfo_file($finfo, $file);
         finfo_close($finfo);
         $pathinfo = pathinfo($file);
         if ($pathinfo['extension'] == 'css') {
             $mime = 'text/css';
         }
         if ($pathinfo['extension'] == 'js') {
             $mime = 'application/javascript';
         }
         if ($pathinfo['extension'] == 'svg') {
             $mime = 'image/svg+xml';
         }
         if (substr($mime, 0, 15) == 'application/xml' && ($pathinfo['extension'] == 'htm' || $pathinfo['extension'] == 'html')) {
             $mime = 'application/xhtml+xml';
         }
         $response->setHeader('Content-Type', $mime);
         $response->appendData(file_get_contents($file));
     });
 }
开发者ID:tomaka17,项目名称:niysu,代码行数:42,代码来源:RoutesCollection.php

示例3: mime_type

 function mime_type($file_path)
 {
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime_type = finfo_file($finfo, $file_path);
     finfo_close($finfo);
     return $mime_type;
 }
开发者ID:zachborboa,项目名称:php-curl-class,代码行数:7,代码来源:Helper.php

示例4: check

 /**
  * Check file mime type
  * @access	public
  * @param 	string $name
  * @param 	string $path
  * @param 	string $type
  * @return 	bool
  */
 public function check($name, $path)
 {
     $extension = strtolower(substr($name, strrpos($name, '.') + 1));
     if (function_exists('finfo_open')) {
         if ($finfo = @finfo_open(FILEINFO_MIME_TYPE)) {
             if ($mimetype = @finfo_file($finfo, $path)) {
                 @finfo_close($finfo);
                 $mime = self::getMime($mimetype);
                 if ($mime) {
                     return in_array($extension, $mime);
                 }
             }
         }
     } else {
         if (function_exists('mime_content_type')) {
             if ($mimetype = @mime_content_type($path)) {
                 $mime = self::getMime($mimetype);
                 if ($mime) {
                     return in_array($extension, $mime);
                 }
             }
         }
     }
     // server doesn't support mime type check, let it through...
     return true;
 }
开发者ID:DanyCan,项目名称:wisten.github.io,代码行数:34,代码来源:mime.php

示例5: upload

 public static function upload($file, $path = "", $fileName = NULL, $_mime = NULL)
 {
     //----------------------------------------------------------
     //init var
     //----------------------------------------------------------
     $chk = array("bool" => true, 'result' => array(), "func" => "upload");
     //----------------------------------------------------------
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $mime = finfo_file($finfo, $file);
     finfo_close($finfo);
     if (!is_null($_mime)) {
         $mime = $_mime;
     }
     //----------------------------------------------------------
     $client = S3Client::factory(array('credentials' => array('key' => S3::$key, 'secret' => S3::$secret)));
     //----------------------------------------------------------
     try {
         $chk['result'] = $client->putObject(['Bucket' => S3::$bucket, 'Key' => $path . (!is_null($fileName) ? $fileName : basename($file)), 'Body' => fopen($file, r), 'ACL' => 'public-read', 'ContentType' => $mime]);
     } catch (S3Exception $e) {
         $chk['bool'] = false;
         $chk['message'] = "upload to s3 bucket: " . S3::$bucket . " failed!!!";
     }
     //----------------------------------------------------------
     return $chk;
 }
开发者ID:awwthentic1234,项目名称:hey,代码行数:25,代码来源:S3.php

示例6: get_file_mime_type

 function get_file_mime_type($filename, $debug = false)
 {
     if (function_exists('finfo_open') && function_exists('finfo_file') && function_exists('finfo_close')) {
         $fileinfo = finfo_open(FILEINFO_MIME);
         $mime_type = finfo_file($fileinfo, $filename);
         finfo_close($fileinfo);
         if (!empty($mime_type)) {
             if (true === $debug) {
                 return array('mime_type' => $mime_type, 'method' => 'fileinfo');
             }
             return $mime_type;
         }
     }
     if (function_exists('mime_content_type')) {
         $mime_type = mime_content_type($filename);
         if (!empty($mime_type)) {
             if (true === $debug) {
                 return array('mime_type' => $mime_type, 'method' => 'mime_content_type');
             }
             return $mime_type;
         }
     }
     $mime_types = array('ai' => 'application/postscript', 'aif' => 'audio/x-aiff', 'aifc' => 'audio/x-aiff', 'aiff' => 'audio/x-aiff', 'asc' => 'text/plain', 'asf' => 'video/x-ms-asf', 'asx' => 'video/x-ms-asf', 'au' => 'audio/basic', 'avi' => 'video/x-msvideo', 'bcpio' => 'application/x-bcpio', 'bin' => 'application/octet-stream', 'bmp' => 'image/bmp', 'bz2' => 'application/x-bzip2', 'cdf' => 'application/x-netcdf', 'chrt' => 'application/x-kchart', 'class' => 'application/octet-stream', 'cpio' => 'application/x-cpio', 'cpt' => 'application/mac-compactpro', 'csh' => 'application/x-csh', 'css' => 'text/css', 'dcr' => 'application/x-director', 'dir' => 'application/x-director', 'djv' => 'image/vnd.djvu', 'djvu' => 'image/vnd.djvu', 'dll' => 'application/octet-stream', 'dms' => 'application/octet-stream', 'doc' => 'application/msword', 'dvi' => 'application/x-dvi', 'dxr' => 'application/x-director', 'eps' => 'application/postscript', 'etx' => 'text/x-setext', 'exe' => 'application/octet-stream', 'ez' => 'application/andrew-inset', 'flv' => 'video/x-flv', 'gif' => 'image/gif', 'gtar' => 'application/x-gtar', 'gz' => 'application/x-gzip', 'hdf' => 'application/x-hdf', 'hqx' => 'application/mac-binhex40', 'htm' => 'text/html', 'html' => 'text/html', 'ice' => 'x-conference/x-cooltalk', 'ief' => 'image/ief', 'iges' => 'model/iges', 'igs' => 'model/iges', 'img' => 'application/octet-stream', 'iso' => 'application/octet-stream', 'jad' => 'text/vnd.sun.j2me.app-descriptor', 'jar' => 'application/x-java-archive', 'jnlp' => 'application/x-java-jnlp-file', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'js' => 'application/x-javascript', 'kar' => 'audio/midi', 'kil' => 'application/x-killustrator', 'kpr' => 'application/x-kpresenter', 'kpt' => 'application/x-kpresenter', 'ksp' => 'application/x-kspread', 'kwd' => 'application/x-kword', 'kwt' => 'application/x-kword', 'latex' => 'application/x-latex', 'lha' => 'application/octet-stream', 'lzh' => 'application/octet-stream', 'm3u' => 'audio/x-mpegurl', 'man' => 'application/x-troff-man', 'me' => 'application/x-troff-me', 'mesh' => 'model/mesh', 'mid' => 'audio/midi', 'midi' => 'audio/midi', 'mif' => 'application/vnd.mif', 'mov' => 'video/quicktime', 'movie' => 'video/x-sgi-movie', 'mp2' => 'audio/mpeg', 'mp3' => 'audio/mpeg', 'mpe' => 'video/mpeg', 'mpeg' => 'video/mpeg', 'mpg' => 'video/mpeg', 'mpga' => 'audio/mpeg', 'ms' => 'application/x-troff-ms', 'msh' => 'model/mesh', 'mxu' => 'video/vnd.mpegurl', 'nc' => 'application/x-netcdf', 'odb' => 'application/vnd.oasis.opendocument.database', 'odc' => 'application/vnd.oasis.opendocument.chart', 'odf' => 'application/vnd.oasis.opendocument.formula', 'odg' => 'application/vnd.oasis.opendocument.graphics', 'odi' => 'application/vnd.oasis.opendocument.image', 'odm' => 'application/vnd.oasis.opendocument.text-master', 'odp' => 'application/vnd.oasis.opendocument.presentation', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', 'odt' => 'application/vnd.oasis.opendocument.text', 'ogg' => 'application/ogg', 'otg' => 'application/vnd.oasis.opendocument.graphics-template', 'oth' => 'application/vnd.oasis.opendocument.text-web', 'otp' => 'application/vnd.oasis.opendocument.presentation-template', 'ots' => 'application/vnd.oasis.opendocument.spreadsheet-template', 'ott' => 'application/vnd.oasis.opendocument.text-template', 'pbm' => 'image/x-portable-bitmap', 'pdb' => 'chemical/x-pdb', 'pdf' => 'application/pdf', 'pgm' => 'image/x-portable-graymap', 'pgn' => 'application/x-chess-pgn', 'png' => 'image/png', 'pnm' => 'image/x-portable-anymap', 'ppm' => 'image/x-portable-pixmap', 'ppt' => 'application/vnd.ms-powerpoint', 'ps' => 'application/postscript', 'qt' => 'video/quicktime', 'ra' => 'audio/x-realaudio', 'ram' => 'audio/x-pn-realaudio', 'ras' => 'image/x-cmu-raster', 'rgb' => 'image/x-rgb', 'rm' => 'audio/x-pn-realaudio', 'roff' => 'application/x-troff', 'rpm' => 'application/x-rpm', 'rtf' => 'text/rtf', 'rtx' => 'text/richtext', 'sgm' => 'text/sgml', 'sgml' => 'text/sgml', 'sh' => 'application/x-sh', 'shar' => 'application/x-shar', 'silo' => 'model/mesh', 'sis' => 'application/vnd.symbian.install', 'sit' => 'application/x-stuffit', 'skd' => 'application/x-koan', 'skm' => 'application/x-koan', 'skp' => 'application/x-koan', 'skt' => 'application/x-koan', 'smi' => 'application/smil', 'smil' => 'application/smil', 'snd' => 'audio/basic', 'so' => 'application/octet-stream', 'spl' => 'application/x-futuresplash', 'src' => 'application/x-wais-source', 'stc' => 'application/vnd.sun.xml.calc.template', 'std' => 'application/vnd.sun.xml.draw.template', 'sti' => 'application/vnd.sun.xml.impress.template', 'stw' => 'application/vnd.sun.xml.writer.template', 'sv4cpio' => 'application/x-sv4cpio', 'sv4crc' => 'application/x-sv4crc', 'swf' => 'application/x-shockwave-flash', 'sxc' => 'application/vnd.sun.xml.calc', 'sxd' => 'application/vnd.sun.xml.draw', 'sxg' => 'application/vnd.sun.xml.writer.global', 'sxi' => 'application/vnd.sun.xml.impress', 'sxm' => 'application/vnd.sun.xml.math', 'sxw' => 'application/vnd.sun.xml.writer', 't' => 'application/x-troff', 'tar' => 'application/x-tar', 'tcl' => 'application/x-tcl', 'tex' => 'application/x-tex', 'texi' => 'application/x-texinfo', 'texinfo' => 'application/x-texinfo', 'tgz' => 'application/x-gzip', 'tif' => 'image/tiff', 'tiff' => 'image/tiff', 'torrent' => 'application/x-bittorrent', 'tr' => 'application/x-troff', 'tsv' => 'text/tab-separated-values', 'txt' => 'text/plain', 'ustar' => 'application/x-ustar', 'vcd' => 'application/x-cdlink', 'vrml' => 'model/vrml', 'wav' => 'audio/x-wav', 'wax' => 'audio/x-ms-wax', 'wbmp' => 'image/vnd.wap.wbmp', 'wbxml' => 'application/vnd.wap.wbxml', 'wm' => 'video/x-ms-wm', 'wma' => 'audio/x-ms-wma', 'wml' => 'text/vnd.wap.wml', 'wmlc' => 'application/vnd.wap.wmlc', 'wmls' => 'text/vnd.wap.wmlscript', 'wmlsc' => 'application/vnd.wap.wmlscriptc', 'wmv' => 'video/x-ms-wmv', 'wmx' => 'video/x-ms-wmx', 'wrl' => 'model/vrml', 'wvx' => 'video/x-ms-wvx', 'xbm' => 'image/x-xbitmap', 'xht' => 'application/xhtml+xml', 'xhtml' => 'application/xhtml+xml', 'xls' => 'application/vnd.ms-excel', 'xml' => 'text/xml', 'xpm' => 'image/x-xpixmap', 'xsl' => 'text/xml', 'xwd' => 'image/x-xwindowdump', 'xyz' => 'chemical/x-xyz', 'zip' => 'application/zip');
     $ext = strtolower(array_pop(explode('.', $filename)));
     if (!empty($mime_types[$ext])) {
         if (true === $debug) {
             return array('mime_type' => $mime_types[$ext], 'method' => 'from_array');
         }
         return $mime_types[$ext];
     }
     if (true === $debug) {
         return array('mime_type' => 'application/octet-stream', 'method' => 'last_resort');
     }
     return 'application/octet-stream';
 }
开发者ID:rad4n,项目名称:erekutoro,代码行数:35,代码来源:mime_type_lib.php

示例7: forceDownload

function forceDownload($file)
{
    //Check file exist or not
    if (file_exists($file)) {
        if (ini_get('zlib.output_compression')) {
            // required for IE
            ini_set('zlib.output_compression', 'Off');
        }
        // Get mine type of file.
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        // return mime type ala mimetype extension
        $mimeType = finfo_file($finfo, $file) . "\n";
        finfo_close($finfo);
        header('Expires: 0');
        header('Pragma: public');
        header('Cache-Control: private', false);
        header('Content-Type:' . $mimeType);
        header('Content-Disposition: attachment; filename="' . basename($file) . '"');
        header('Content-Transfer-Encoding: binary');
        header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
        header('Content-Length: ' . filesize($file));
        header('Connection: close');
        readfile($file);
        exit;
    } else {
        return "File does not exist";
    }
}
开发者ID:hiiamrohit,项目名称:force-download-php,代码行数:28,代码来源:index.php

示例8: detect

 /**
  * detect mimetype based on both filename and content
  *
  * @param string $path
  * @return string
  */
 public function detect($path)
 {
     if (@is_dir($path)) {
         // directories are easy
         return "httpd/unix-directory";
     }
     $mimeType = $this->detectPath($path);
     if ($mimeType === 'application/octet-stream' and function_exists('finfo_open') and function_exists('finfo_file') and $finfo = finfo_open(FILEINFO_MIME)) {
         $info = @strtolower(finfo_file($finfo, $path));
         finfo_close($finfo);
         if ($info) {
             $mimeType = substr($info, 0, strpos($info, ';'));
             return empty($mimeType) ? 'application/octet-stream' : $mimeType;
         }
     }
     $isWrapped = strpos($path, '://') !== false and substr($path, 0, 7) === 'file://';
     if (!$isWrapped and $mimeType === 'application/octet-stream' && function_exists("mime_content_type")) {
         // use mime magic extension if available
         $mimeType = mime_content_type($path);
     }
     if (!$isWrapped and $mimeType === 'application/octet-stream' && \OC_Helper::canExecute("file")) {
         // it looks like we have a 'file' command,
         // lets see if it does have mime support
         $path = escapeshellarg($path);
         $fp = popen("file -b --mime-type {$path} 2>/dev/null", "r");
         $reply = fgets($fp);
         pclose($fp);
         //trim the newline
         $mimeType = trim($reply);
         if (empty($mimeType)) {
             $mimeType = 'application/octet-stream';
         }
     }
     return $mimeType;
 }
开发者ID:Kevin-ZK,项目名称:vaneDisk,代码行数:41,代码来源:detection.php

示例9: getMime

	public static function getMime($file)
	{
		// Check if file is an image.
		$info = @getimagesize($file);

		if ($info)
		{
			$type = $info['mime'];
		}
		elseif (function_exists('finfo_open'))
		{
			// We have fileinfo.
			$finfo = finfo_open(FILEINFO_MIME_TYPE);
			$type  = finfo_file($finfo, $file);
			finfo_close($finfo);
		}
		elseif (function_exists('mime_content_type'))
		{
			// We have mime magic.
			$type = mime_content_type($file);
		}
		else
		{
			$type = false;
		}

		return $type;
	}
开发者ID:BillVGN,项目名称:PortalPRP,代码行数:28,代码来源:file.php

示例10: check

 /**
  * Check file mime type
  * @access	public
  * @param 	string $name
  * @param 	string $path
  * @param 	string $type
  * @return 	bool
  */
 public function check($name, $path)
 {
     $extension = strtolower(substr($name, strrpos($name, '.') + 1));
     $ms_x = array('docx', 'pptx', 'ppsx', 'xlsx', 'sldx', 'potx', 'xltx', 'dotx');
     if (function_exists('finfo_open')) {
         if ($finfo = @finfo_open(FILEINFO_MIME_TYPE)) {
             if ($mimetype = @finfo_file($finfo, $path)) {
                 @finfo_close($finfo);
                 // we can't validate these files...
                 if ($mimetype === 'application/zip' && in_array($extension, $ms_x)) {
                     return true;
                 }
                 if ($mime = self::getMime($mimetype)) {
                     return in_array($extension, $mime);
                 }
             }
         }
     } else {
         if (function_exists('mime_content_type')) {
             if ($mimetype = @mime_content_type($path)) {
                 // we can't validate these files...
                 if ($mimetype === 'application/zip' && in_array($extension, $ms_x)) {
                     return true;
                 }
                 if ($mime = self::getMime($mimetype)) {
                     return in_array($extension, $mime);
                 }
             }
         }
     }
     // server doesn't support mime type check, let it through...
     return true;
 }
开发者ID:01J,项目名称:bealtine,代码行数:41,代码来源:mime.php

示例11: get_mime

function get_mime($file, $default = "application/octet-stream")
{
    if (function_exists("mime_content_type")) {
        $mime = mime_content_type($file);
        if (!empty($mime)) {
            return $mime;
        }
    }
    if (function_exists("finfo_file")) {
        $finfo = finfo_open(FILEINFO_MIME_TYPE);
        $mime = finfo_file($finfo, $file);
        finfo_close($finfo);
        if (!empty($mime)) {
            return $mime;
        }
    }
    if (!stristr(ini_get("disable_functions"), "shell_exec")) {
        $file = escapeshellarg($file);
        $mime = shell_exec("file -bi " . $file);
        if (!empty($mime)) {
            return $mime;
        }
    }
    return $default;
}
开发者ID:skylogic004,项目名称:Piwigo-URL-Uploader,代码行数:25,代码来源:functions.inc.php

示例12: getMime

 public function getMime()
 {
     $mimeType = false;
     if (is_file($this->file)) {
         if (function_exists('finfo_open')) {
             $finfo = finfo_open(FILEINFO_MIME_TYPE);
             $mimeType = finfo_file($finfo, $this->file);
             finfo_close($finfo);
         }
         if (!$mimeType && function_exists('mime_content_type')) {
             $mimeType = mime_content_type($this->file);
         }
         // 			if( !$mimeType && function_exists('exec') && function_exists('escapeshellarg') )
         // 			{
         // 				if( $cmdOut = trim(exec('file --mime-type -b ' . escapeshellarg( $this->file ))) )
         // 				{
         // 					$mimeType = $cmdOut;
         // 				}
         // 			}
         if (!$mimeType && function_exists('pathinfo') && ($pathinfo = pathinfo($this->file))) {
             $imagetypes = array('gif', 'jpeg', 'jpg', 'png', 'swf', 'psd', 'bmp', 'tiff', 'tif', 'jpc', 'jp2', 'jpx', 'jb2', 'swc', 'iff', 'wbmp', 'xbm', 'ico');
             if (in_array($pathinfo['extension'], $imagetypes) && getimagesize($this->file)) {
                 $imageinfo = getimagesize($this->file);
                 $mimeType = $imageinfo['mime'];
             }
         }
         if (!$mimeType) {
             $mimeType = 'application/octet-stream';
         }
     }
     return $mimeType;
 }
开发者ID:Tommar,项目名称:vino2,代码行数:32,代码来源:item.php

示例13: isPicture

function isPicture($file, $types = NULL)
{
    /* Detect mime content type */
    $mimeType = false;
    if (!$types) {
        $types = array('image/gif', 'image/jpg', 'image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png');
    }
    /* Try 4 different methods to determine the mime type */
    if (function_exists('finfo_open')) {
        $const = defined('FILEINFO_MIME_TYPE') ? FILEINFO_MIME_TYPE : FILEINFO_MIME;
        $finfo = finfo_open($const);
        $mimeType = finfo_file($finfo, $file['tmp_name']);
        finfo_close($finfo);
    } elseif (function_exists('mime_content_type')) {
        $mimeType = mime_content_type($file['tmp_name']);
    } elseif (function_exists('exec')) {
        $mimeType = trim(exec('file -b --mime-type ' . escapeshellarg($file['tmp_name'])));
        if (!$mimeType) {
            $mimeType = trim(exec('file --mime ' . escapeshellarg($file['tmp_name'])));
        }
        if (!$mimeType) {
            $mimeType = trim(exec('file -bi ' . escapeshellarg($file['tmp_name'])));
        }
    }
    if (empty($mimeType) or $mimeType == 'regular file' or $mimeType == 'text/plain') {
        $mimeType = $file['type'];
    }
    /* For each allowed MIME type, we are looking for it inside the current MIME type */
    foreach ($types as $type) {
        if (strstr($mimeType, $type)) {
            return true;
        }
    }
    return false;
}
开发者ID:arribanz,项目名称:live,代码行数:35,代码来源:assets.php

示例14: isBinary

 public static function isBinary($path)
 {
     if (false === is_readable($path)) {
         Exception::raise($path . ' is not readable', 2);
     }
     $size = filesize($path);
     if ($size < 2) {
         return false;
     }
     $data = file_get_contents($path, false, null, -1, 5012);
     if (false && function_exists('finfo_open')) {
         $finfo = finfo_open(FILEINFO_MIME_ENCODING);
         $encode = finfo_buffer($finfo, $data, FILEINFO_MIME_ENCODING);
         finfo_close($finfo);
         $data = null;
         return $encode === 'binary';
     }
     $buffer = '';
     for ($i = 0; $i < $size; ++$i) {
         if (isset($data[$i])) {
             $buffer .= sprintf('%08b', ord($data[$i]));
         }
     }
     $data = null;
     return preg_match('#^[0-1]+$#', $buffer) === 1;
 }
开发者ID:inphinit,项目名称:framework,代码行数:26,代码来源:File.php

示例15: fileMimeType

 private function fileMimeType($filePath)
 {
     $finfo = finfo_open(FILEINFO_MIME_TYPE);
     $type = finfo_file($finfo, $filePath);
     finfo_close($finfo);
     return $type;
 }
开发者ID:simnom,项目名称:Europeana-Professional,代码行数:7,代码来源:Extension.php


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