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}\"."); } }
<?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);