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


PHP PhocaGalleryFile::getMimeType方法代码示例

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


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

示例1: download

 function download($item, $backLink, $extLink = 0)
 {
     $app = JFactory::getApplication();
     if (empty($item)) {
         $msg = JText::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
         $app->redirect($backLink, $msg);
         return false;
     } else {
         if ($extLink == 0) {
             phocagalleryimport('phocagallery.file.file');
             $fileOriginal = PhocaGalleryFile::getFileOriginal($item->filenameno);
             if (!JFile::exists($fileOriginal)) {
                 $msg = JText::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
                 $app->redirect($backLink, $msg);
                 return false;
             }
             $fileToDownload = $item->filenameno;
             $fileNameToDownload = $item->filename;
         } else {
             $fileToDownload = $item->exto;
             $fileNameToDownload = $item->title;
             $fileOriginal = $item->exto;
         }
         // Clears file status cache
         clearstatcache();
         $fileOriginal = $fileOriginal;
         $fileSize = @filesize($fileOriginal);
         $mimeType = PhocaGalleryFile::getMimeType($fileToDownload);
         $fileName = $fileNameToDownload;
         // Clean the output buffer
         ob_end_clean();
         header("Cache-Control: public, must-revalidate");
         header('Cache-Control: pre-check=0, post-check=0, max-age=0');
         header("Pragma: no-cache");
         header("Expires: 0");
         header("Content-Description: File Transfer");
         header("Expires: Sat, 30 Dec 1990 07:07:07 GMT");
         header("Content-Type: " . (string) $mimeType);
         // Problem with IE
         if ($extLink == 0) {
             header("Content-Length: " . (string) $fileSize);
         }
         header('Content-Disposition: attachment; filename="' . $fileName . '"');
         header("Content-Transfer-Encoding: binary\n");
         @readfile($fileOriginal);
         exit;
     }
     return false;
 }
开发者ID:optimosolution,项目名称:marhk,代码行数:49,代码来源:filedownload.php

示例2: download

 public static function download($item, $backLink, $extLink = 0)
 {
     $app = JFactory::getApplication();
     if (empty($item)) {
         $msg = JText::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
         $app->redirect($backLink, $msg);
         return false;
     } else {
         if ($extLink == 0) {
             phocagalleryimport('phocagallery.file.file');
             $fileOriginal = PhocaGalleryFile::getFileOriginal($item->filenameno);
             if (!JFile::exists($fileOriginal)) {
                 $msg = JText::_('COM_PHOCAGALLERY_ERROR_DOWNLOADING_FILE');
                 $app->redirect($backLink, $msg);
                 return false;
             }
             $fileToDownload = $item->filenameno;
             $fileNameToDownload = $item->filename;
         } else {
             $fileToDownload = $item->exto;
             $fileNameToDownload = $item->title;
             $fileOriginal = $item->exto;
         }
         // Clears file status cache
         clearstatcache();
         $fileOriginal = $fileOriginal;
         $fileSize = @filesize($fileOriginal);
         $mimeType = PhocaGalleryFile::getMimeType($fileToDownload);
         $fileName = $fileNameToDownload;
         if ($extLink > 0) {
             $content = '';
             if (function_exists('curl_init')) {
                 $ch = curl_init();
                 curl_setopt($ch, CURLOPT_URL, $fileOriginal);
                 curl_setopt($ch, CURLOPT_HEADER, 0);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                 $downloadedFile = fopen($fileName, 'w+');
                 curl_setopt($ch, CURLOPT_FILE, $downloadedFile);
                 $content = curl_exec($ch);
                 $fileSize = strlen($content);
                 curl_close($ch);
                 fclose($downloadedFile);
             }
             if ($content != '') {
                 // Clean the output buffer
                 ob_end_clean();
                 header("Cache-Control: public, must-revalidate");
                 header('Cache-Control: pre-check=0, post-check=0, max-age=0');
                 header("Pragma: no-cache");
                 header("Expires: 0");
                 header("Content-Description: File Transfer");
                 header("Expires: Sat, 30 Dec 1990 07:07:07 GMT");
                 header("Content-Type: " . (string) $mimeType);
                 header("Content-Length: " . (string) $fileSize);
                 header('Content-Disposition: attachment; filename="' . $fileName . '"');
                 header("Content-Transfer-Encoding: binary\n");
                 echo $content;
                 exit;
             }
         } else {
             // Clean the output buffer
             ob_end_clean();
             header("Cache-Control: public, must-revalidate");
             header('Cache-Control: pre-check=0, post-check=0, max-age=0');
             header("Pragma: no-cache");
             header("Expires: 0");
             header("Content-Description: File Transfer");
             header("Expires: Sat, 30 Dec 1990 07:07:07 GMT");
             header("Content-Type: " . (string) $mimeType);
             // Problem with IE
             if ($extLink == 0) {
                 header("Content-Length: " . (string) $fileSize);
             }
             header('Content-Disposition: attachment; filename="' . $fileName . '"');
             header("Content-Transfer-Encoding: binary\n");
             @readfile($fileOriginal);
             exit;
         }
     }
     return false;
 }
开发者ID:naka211,项目名称:malerfirmaet,代码行数:81,代码来源:filedownload.php


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