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


PHP get_mime_by_extension函数代码示例

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


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

示例1: index

 function index()
 {
     $fn = substr($this->uri->uri_string(), 1);
     if (file_exists($fn)) {
         if (function_exists('apache_request_headers')) {
             $headers = apache_request_headers();
         }
         // Checking if the client is validating his cache and if it is current.
         if (isset($headers['If-Modified-Since']) && strtotime($headers['If-Modified-Since']) == filemtime($fn)) {
             // Client's cache IS current, so we just respond '304 Not Modified'.
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fn)) . ' GMT', true, 304);
         } else {
             // Image not cached or cache outdated, we respond '200 OK' and output the image.
             header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fn)) . ' GMT', true, 200);
             header('Content-Length: ' . filesize($fn));
             $this->load->helper('file');
             $mime = get_mime_by_extension($fn);
             header('Content-Type: $mime');
             print file_get_contents($fn);
         }
     } else {
         $this->output->set_header("HTTP/1.0 404 Not Found");
         echo "Not found";
     }
 }
开发者ID:wildanSawaludin,项目名称:ci-cms,代码行数:25,代码来源:media.php

示例2: pic_thumb

 function pic_thumb($pic_id)
 {
     $this->load->helper('file');
     $this->load->library('image_lib');
     $base_path = "uploads/item_pics/" . $pic_id;
     $images = glob($base_path . "*");
     if (sizeof($images) > 0) {
         $image_path = $images[0];
         $ext = pathinfo($image_path, PATHINFO_EXTENSION);
         $thumb_path = $base_path . $this->image_lib->thumb_marker . '.' . $ext;
         if (sizeof($images) < 2) {
             $config['image_library'] = 'gd2';
             $config['source_image'] = $image_path;
             $config['maintain_ratio'] = TRUE;
             $config['create_thumb'] = TRUE;
             $config['width'] = 52;
             $config['height'] = 32;
             $this->image_lib->initialize($config);
             $image = $this->image_lib->resize();
             $thumb_path = $this->image_lib->full_dst_path;
         }
         $this->output->set_content_type(get_mime_by_extension($thumb_path));
         $this->output->set_output(file_get_contents($thumb_path));
     }
 }
开发者ID:Exactpk,项目名称:opensourcepos,代码行数:25,代码来源:items.php

示例3: get

 function get($filename)
 {
     $id = $this->input->get('id');
     $token = $this->input->get('token');
     //Chequeamos permisos del frontend
     $file = Doctrine_Query::create()->from('File f, f.Tramite t, t.Etapas e, e.Usuario u')->where('f.id = ? AND f.llave = ? AND u.id = ?', array($id, $token, UsuarioSesion::usuario()->id))->fetchOne();
     if (!$file) {
         //Chequeamos permisos en el backend
         $file = Doctrine_Query::create()->from('File f, f.Tramite.Proceso.Cuenta.UsuariosBackend u')->where('f.id = ? AND f.llave = ? AND u.id = ? AND (u.rol="super" OR u.rol="operacion" OR u.rol="seguimiento")', array($id, $token, UsuarioBackendSesion::usuario()->id))->fetchOne();
         if (!$file) {
             echo 'Usuario no tiene permisos para ver este archivo.';
             exit;
         }
     }
     $path = 'uploads/documentos/' . $file->filename;
     if (preg_match('/^\\.\\./', $file->filename)) {
         echo 'Archivo invalido';
         exit;
     }
     if (!file_exists($path)) {
         echo 'Archivo no existe';
         exit;
     }
     $friendlyName = str_replace(' ', '-', convert_accented_characters(mb_convert_case($file->Tramite->Proceso->Cuenta->nombre . ' ' . $file->Tramite->Proceso->nombre, MB_CASE_LOWER) . '-' . $file->id)) . '.' . pathinfo($path, PATHINFO_EXTENSION);
     header('Content-Type: ' . get_mime_by_extension($path));
     header('Content-Length: ' . filesize($path));
     header('Content-Disposition: attachment; filename="' . $friendlyName . '"');
     readfile($path);
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:29,代码来源:documentos.php

示例4: mime_type

 public function mime_type()
 {
     $ext = end(explode('.', $this->path));
     if (in_array($ext, array('htm', 'html', 'php', 'phtml', 'php3', 'php4', 'php5', 'php5', 'php6'))) {
         return 'text/html';
     } else {
         if (in_array($ext, array('js', 'jscript'))) {
             return 'text/javascript';
         } else {
             if (in_array($ext, array('css', 'css3'))) {
                 return 'text/css';
             } else {
                 if (in_array($ext, array('sql'))) {
                     return 'text/plain';
                 } else {
                     if (in_array($ext, array('jpg', 'jpeg', 'png', 'gif'))) {
                         return 'image/' . str_replace('jpg', 'jpeg', $ext);
                     } else {
                         return get_mime_by_extension($this->path);
                     }
                 }
             }
         }
     }
 }
开发者ID:jotavejv,项目名称:CMS,代码行数:25,代码来源:file.php

示例5: __construct

 function __construct()
 {
     parent::__construct();
     $this->load->library('uri');
     $this->load->helper('file');
     $segments = $this->uri->segment_array();
     array_shift($segments);
     $path = APPPATH . '../assets';
     foreach ($segments as $segment) {
         $path .= '/' . $segment;
     }
     if (realpath($path) !== false) {
         $data = read_file($path);
         if (php_sapi_name() == 'apache2handler' || php_sapi_name() == 'apache') {
             $headers = apache_request_headers();
             if (isset($headers['If-Modified-Since']) && !empty($headers['If-Modified-Since'])) {
                 header('Not Modified', true, 304);
                 exit;
             }
         }
         header('Content-Type: ' . get_mime_by_extension(basename($path)));
         header('Cache-Control: max-age=3600, must-revalidate');
         header('Last-Modified: ' . standard_date('DATE_COOKIE', filemtime($path)));
         echo $data;
         exit;
     } else {
         show_error('Asset does not exist in repository.', 404);
     }
 }
开发者ID:pcisneros,项目名称:glab-ci-ext,代码行数:29,代码来源:Assets.php

示例6: get

 public function get($id_media)
 {
     // Pictures data from database
     $picture = $id_media ? $this->media_model->get($id_media) : FALSE;
     $options = $this->uri->uri_to_assoc();
     unset($options['get']);
     if (empty($options['size'])) {
         $options['size'] = 120;
     }
     // Path to the picture
     if ($picture && file_exists($picture_path = DOCPATH . $picture['path'])) {
         $thumb_path = DOCPATH . Settings::get('files_path') . str_replace(Settings::get('files_path') . '/', '/.thumbs/', $picture['base_path']);
         $thumb_file_path = $this->medias->get_thumb_file_path($picture, $options);
         $refresh = !empty($options['refresh']) ? TRUE : FALSE;
         // If no thumb, try to create it
         if (!file_exists($thumb_file_path) or $refresh === TRUE) {
             try {
                 $thumb_file_path = $this->medias->create_thumb(DOCPATH . $picture['path'], $thumb_file_path, $options);
             } catch (Exception $e) {
                 // $return_thumb_path = FCPATH.'themes/'.Settings::get('theme_admin').'/styles/'.Settings::get('backend_ui_style').'/images/icon_48_no_folder_rights.png';
             }
         }
         $mime = get_mime_by_extension($thumb_file_path);
         $content = read_file($thumb_file_path);
         $this->push_thumb($content, $mime, 0);
     } else {
         $mime = 'image/png';
         $content = read_file(FCPATH . 'themes/' . Settings::get('theme_admin') . '/styles/' . Settings::get('backend_ui_style') . '/images/icon_48_no_source_picture.png');
         $this->push_thumb($content, $mime, 0);
     }
 }
开发者ID:rockylo,项目名称:ionize,代码行数:31,代码来源:picture.php

示例7: _serveFile

 /**
  * Publishes a file to user.
  * This method will serve the original file or the browser cached version if available and uppon user settings
  *
  * @param string|null $file
  *
  * @return void
  * @throws 404 not found  if the requested file does not exist.
  */
 private function _serveFile($file = NULL)
 {
     if (!is_file($file)) {
         show_404('requested url is invalid');
     }
     $Modified = filemtime($file);
     $gmdate_mod = gmdate('D, d M Y H:i:s', $Modified) . " GMT";
     if ($this->_usecache) {
         if (isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])) {
             $if_modified_since = preg_replace('/;.*$/', '', $_SERVER['HTTP_IF_MODIFIED_SINCE']);
             if ($if_modified_since >= $gmdate_mod) {
                 $this->CI->output->set_header('HTTP/1.1 304 Not Modified');
                 // HTTP/1.1
                 //header('HTTP/1.1 304 Not Modified');
                 $this->CI->we_are_done = TRUE;
                 exit;
             }
         }
         //no cache found, so we serve original file
     } else {
         $this->CI->output->set_header("Cache-Control: no-cache, must-revalidate");
         //Cache-Controle
         //header("Cache-Control: no-cache, must-revalidate");  // HTTP/1.1
         $this->CI->output->set_header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");
         //Date in the past
         // header("Expires: Sat, 26 Jul 1997 05:00:00 GMT");  // Date in the past
     }
     $mime = get_mime_by_extension($file);
     $this->CI->output->set_header("HTTP/1.0 200 OK")->set_header("HTTP/1.1 200 OK")->set_content_type($mime)->set_header('Last-Modified: ' . $gmdate_mod)->set_header('Content-Length: ' . filesize($file))->set_output(file_get_contents($file));
 }
开发者ID:stimcon-dev,项目名称:ezRbac,代码行数:39,代码来源:ezmedia.php

示例8: index

 /**
  * Performs the image processing based on the parameters provided in the GET request
  *
  * @param string $file The name of the image to return.
  */
 public function index()
 {
     // Quick before it's too late
     $this->output->enable_profiler(false);
     // routing doesn't work (?)
     $config = config_item('assets');
     $request = $config['cache_path'] . str_replace(get_class($this) . '/', '', $this->uri->ruri_string());
     $this->load->helper('file');
     $output = false;
     if (empty($request) || !is_string($request)) {
         // Kill now!
         show_404();
     }
     /*if($_output = $this->cache->file->get($request))
     		{
     			$output = $_output;
     		}*/
     if ($_output = read_file(APPPATH . $request)) {
         $output = $_output;
     }
     if ($output) {
         $this->output->set_content_type(get_mime_by_extension($request))->set_output(trim($output));
     } else {
         show_404();
     }
 }
开发者ID:escproxy,项目名称:RPS,代码行数:31,代码来源:_assets.php

示例9: datos_get

 function datos_get($filename)
 {
     $id = $this->input->get('id');
     $token = $this->input->get('token');
     //Chequeamos los permisos en el frontend
     $file = Doctrine_Query::create()->from('File f, f.Tramite t, t.Etapas e, e.Usuario u')->where('f.id = ? AND f.llave = ? AND u.id = ?', array($id, $token, UsuarioSesion::usuario()->id))->fetchOne();
     if (!$file) {
         //Chequeamos permisos en el backend
         $file = Doctrine_Query::create()->from('File f, f.Tramite.Proceso.Cuenta.UsuariosBackend u')->where('f.id = ? AND f.llave = ? AND u.id = ? AND (u.rol="super" OR u.rol="operacion" OR u.rol="seguimiento")', array($id, $token, UsuarioBackendSesion::usuario()->id))->fetchOne();
         if (!$file) {
             echo 'Usuario no tiene permisos para ver este archivo.';
             exit;
         }
     }
     $path = 'uploads/datos/' . $file->filename;
     if (preg_match('/^\\.\\./', $file->filename)) {
         echo 'Archivo invalido';
         exit;
     }
     if (!file_exists($path)) {
         echo 'Archivo no existe';
         exit;
     }
     header('Content-Type: ' . get_mime_by_extension($path));
     header('Content-Length: ' . filesize($path));
     readfile($path);
 }
开发者ID:chileindica,项目名称:SIMPLE,代码行数:27,代码来源:uploader.php

示例10: get

 function get($file)
 {
     if ($row = $this->downloads->get_doc(array('download_files.file' => $file))) {
         $fn = $this->downloads->settings['upload_path'] . $file;
         if (file_exists($fn)) {
             //counter hit
             if ($this->session->userdata('download_file' . $row['id']) != $row['id']) {
                 $this->session->set_userdata('download_file' . $row['id'], $row['id']);
                 $this->downloads->update_doc(array('hit' => $row['hit'] + 1), $row['id']);
             }
             if (function_exists('apache_request_headers')) {
                 $headers = apache_request_headers();
             }
             // Checking if the client is validating his cache and if it is current.
             if (isset($headers['If-Modified-Since']) && strtotime($headers['If-Modified-Since']) == filemtime($fn)) {
                 // Client's cache IS current, so we just respond '304 Not Modified'.
                 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fn)) . ' GMT', true, 304);
             } else {
                 $this->load->helper('file');
                 // Image not cached or cache outdated, we respond '200 OK' and output the image.
                 header('Last-Modified: ' . gmdate('D, d M Y H:i:s', filemtime($fn)) . ' GMT', true, 200);
                 header('Content-Length: ' . filesize($fn));
                 header('Content-Type: ' . get_mime_by_extension($file));
                 header("Content-Disposition: attachment; filename=\"{$file}\"");
                 print file_get_contents($fn);
             }
         } else {
             $this->output->set_header("HTTP/1.0 404 Not Found");
             $this->layout->load($this->template, '404');
         }
     } else {
         $this->output->set_header("HTTP/1.0 404 Not Found");
         $this->layout->load($this->template, '404');
     }
 }
开发者ID:skullJ,项目名称:ci-cms,代码行数:35,代码来源:document.php

示例11: set_output

function set_output($type, $content)
{
    $CI =& get_instance();
    $CI->load->helper('file');
    $mime = get_mime_by_extension('.' . $type);
    header('Content-type: ' . $mime);
    exit($content);
}
开发者ID:dungtrv,项目名称:google-api-codeigniter,代码行数:8,代码来源:zin_helper.php

示例12: downloadReports

 private function downloadReports()
 {
     $resAjax = new Response_Ajax();
     $this->load->library('library_jasperstarter');
     $java_bin = Helper_Config::getBinaryJava();
     $this->library_jasperstarter->setPathFolderOutput(BASEPATH . '../application/temp');
     $this->library_jasperstarter->setPathJavaBin($java_bin);
     $this->library_jasperstarter->dbGeneric('org.firebirdsql.jdbc.FBDriver', 'jdbc:firebirdsql://localhost:3050/C:\\FireBird\\FTT\\DIGIFORTDB.FDB', 'SYSDBA', 'masterkey');
     //$MY =& MY_Controller::get_instance();
     $date_begin = $this->input->post('date_begin');
     $date_end = $this->input->post('date_end');
     $rpte_tipo = $this->input->post('rpte_tipo');
     $rpte_grupo = $this->input->post('rpte_grupo');
     try {
         $condicion = ' AND 1=1 ';
         if ($rpte_tipo == 'RPTE_CAMARAS_GENERAL') {
             $path_file_jasper = BASEPATH . "../application/reports/camaras_general/report.jasper";
             $file_name_download = "CAMARA_EN_GENERAL";
             $file_name_output = 'camaras_general_' . uniqid();
         } else {
             if ($rpte_tipo == 'RPTE_GRUPOS_CAMARAS') {
                 $path_file_jasper = BASEPATH . "../application/reports/grupos_general/rpte_grupos_general.jasper";
                 $file_name_download = "CAMARA_EN_GENERAL";
                 $file_name_output = 'camaras_general_' . uniqid();
                 //$condicion.=' AND 1=1';
                 foreach ($rpte_grupo as $key => $value) {
                     $condicion .= "AND ( GRUPO_CAMARA = '" . $value . "' )";
                 }
             } else {
                 throw new Exception('ERROR DE EJECCIÓN<br/> COMANDO: Tipo de reporte no encontrado');
             }
         }
         $arrParameter = array('fecha_inicio' => $date_begin, 'fecha_fin' => $date_end, 'condicion' => $condicion);
         /* @var $oReport oReport */
         $oReport = $this->library_jasperstarter->buildReport($path_file_jasper, $file_name_output, $arrParameter, 'xls');
         if (!$oReport->isSuccess()) {
             throw new Exception('ERROR DE EJECCIÓN<br/> COMANDO: ' . $oReport->cmd());
         }
         //$data = file_get_contents( $oReport->filePath() ); // Read the file's contents
         //force_download($file_name_output, $data);
         $mime = get_mime_by_extension($oReport->fileExtension());
         //$mime = "application/pdf";
         ob_clean();
         header("Content-Type: application/force-download");
         //header("Content-Disposition: attachment; filename=$file_name_download.xls");
         header("Content-Transfer-Encoding: binary");
         //header("Content-Length: " . $size);
         header("Content-disposition: attachment; filename={$file_name_download}.xls");
         header("Content-type: {$mime}");
         readfile($oReport->filePath());
     } catch (Exception $err) {
         echo $err->getMessage();
     }
     //echo $resAjax->toJsonEncode();
 }
开发者ID:crodriguezn,项目名称:crossfit-milagro,代码行数:55,代码来源:reportex.php

示例13: view

 function view($tmp = '', $file = '', $type = 'pdf', $att = 0)
 {
     $filename = $tmp . "." . $type;
     if (file_exists($this->thisdir . "/output/" . $filename)) {
         $outfile = $file . "." . $type;
         header('Content-Disposition: ' . ($att == 1 ? 'attachment; ' : '') . 'filename="' . $outfile . '"');
         header('Content-Type: ' . get_mime_by_extension($this->thisdir . "/output/" . $filename));
         header('Content-Length: ' . filesize($this->thisdir . "/output/" . $filename));
         header('Cache-Control: no-store');
         readfile($this->thisdir . "/output/" . $filename);
     }
 }
开发者ID:ibnoe,项目名称:simpatda-thinkfrogs,代码行数:12,代码来源:fastreport.php

示例14: slides_get

 function slides_get()
 {
     $uploadHandler = new UploadHandler($this->directory);
     $files = $this->slidesystem->listContents();
     // echo '<pre>';print_r($files);die;
     $slideCounter = 1;
     $resource = new Collection($files, function (array $file) {
         return ['uri' => 'slides/' . $file['path'], 'mime' => get_mime_by_extension($file['path']), 'name' => $file['path'], 'path' => $file['filename'], 'timestamp' => $file['timestamp']];
     });
     $data = $this->fractal->createData($resource)->toArray();
     $this->response($data);
 }
开发者ID:karsanrichard,项目名称:nqcl,代码行数:12,代码来源:Files.php

示例15: test_get_mime_by_extension

 public function test_get_mime_by_extension()
 {
     $content = 'Jack and Jill went up the mountain to fight a billy goat.';
     $file = vfsStream::newFile('my_file.txt', 0777)->withContent($content)->lastModified(time() - 86400)->at($this->_test_dir);
     $this->assertEquals('text/plain', get_mime_by_extension(vfsStream::url('my_file.txt')));
     // Test a mime with an array, such as png
     $file = vfsStream::newFile('foo.png')->at($this->_test_dir);
     $this->assertEquals('image/png', get_mime_by_extension(vfsStream::url('foo.png')));
     // Test a file not in the mimes array
     $file = vfsStream::newFile('foo.blarfengar')->at($this->_test_dir);
     $this->assertFalse(get_mime_by_extension(vfsStream::url('foo.blarfengar')));
 }
开发者ID:ishawge,项目名称:No-CMS,代码行数:12,代码来源:file_helper_test.php


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