本文整理汇总了PHP中MimeMagic::get方法的典型用法代码示例。如果您正苦于以下问题:PHP MimeMagic::get方法的具体用法?PHP MimeMagic::get怎么用?PHP MimeMagic::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MimeMagic
的用法示例。
在下文中一共展示了MimeMagic::get方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _displayFile
private function _displayFile()
{
$registry = Zend_Registry::getInstance();
// Print the contents of the file
$file = $registry->configuration->testcase->dir . '/' . $this->getRequest()->getParam(2);
if ($stream = fopen($file, 'r')) {
// Disable layout
$layout = Zend_Layout::getMvcInstance();
$layout->disableLayout();
/// @todo: output headers and file information
$mm = new MimeMagic();
/// @todo: fix in mimemagic instead
header('Content-type: ' . $mm->get(realpath($file)));
echo stream_get_contents($stream);
fclose($stream);
} else {
throw new Exception("Attempted to view a non-existing file \"{$file}\".");
}
}
示例2: realpath
<?php
/*$file = realpath('C:\\xampp\\htdocs\\apache_pb2.gif');
echo $file.' mime is "'.mime_content_type($file).'"';*/
$filename = realpath('class_vars_for_RDI.php');
$filename = realpath('../../apache_pb2.gif');
$mimefile = 'C:\\xampp\\htdocs\\wtf2\\library\\mime\\magic';
/*
$handle = finfo_open(FILEINFO_MIME,'C:/xampp/php/extras/magic');
var_dump($handle);
$mime_type = finfo_file($handle,$file);
echo $mime_type;
*/
/*
$finfo = new finfo(FILEINFO_MIME, $mimefile);
if (!$finfo) {
echo "Opening fileinfo database failed";
exit();
}
// get mime-type for a specific file
echo $finfo->file($filename);
*/
require_once 'C:\\xampp\\htdocs\\wtf2\\library\\mime\\MimeMagic.class.php';
$mm = new MimeMagic();
echo $mm->get($filename);