當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FileToolkit::getMimeTypeByExtension方法代碼示例

本文整理匯總了PHP中Topxia\Common\FileToolkit::getMimeTypeByExtension方法的典型用法代碼示例。如果您正苦於以下問題:PHP FileToolkit::getMimeTypeByExtension方法的具體用法?PHP FileToolkit::getMimeTypeByExtension怎麽用?PHP FileToolkit::getMimeTypeByExtension使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Topxia\Common\FileToolkit的用法示例。


在下文中一共展示了FileToolkit::getMimeTypeByExtension方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: createPrivateFileDownloadResponse

 protected function createPrivateFileDownloadResponse(Request $request, $file)
 {
     $response = BinaryFileResponse::create($file['fullpath'], 200, array(), false);
     $response->trustXSendfileTypeHeader();
     $file['filename'] = urlencode($file['filename']);
     if (preg_match("/MSIE/i", $request->headers->get('User-Agent'))) {
         $response->headers->set('Content-Disposition', 'attachment; filename="' . $file['filename'] . '"');
     } else {
         $response->headers->set('Content-Disposition', "attachment; filename*=UTF-8''" . $file['filename']);
     }
     $mimeType = FileToolkit::getMimeTypeByExtension($file['ext']);
     if ($mimeType) {
         $response->headers->set('Content-Type', $mimeType);
     }
     return $response;
 }
開發者ID:latticet,項目名稱:EduSoho_jb51,代碼行數:16,代碼來源:CourseMaterialController.php

示例2: getLocalVideo

 public function getLocalVideo()
 {
     $fileId = $this->getParam("targetId");
     $user = $this->controller->getuserByToken($this->request);
     if (!$user->isLogin()) {
         return $this->createErrorResponse('not_login', "您尚未登錄!");
     }
     $file = $this->getUploadFileService()->getFile($fileId);
     if (empty($file)) {
         return $this->createErrorResponse('error', "視頻文件不存在!");
     }
     $response = BinaryFileResponse::create($file['fullpath'], 200, array(), false);
     $response->trustXSendfileTypeHeader();
     $mimeType = FileToolkit::getMimeTypeByExtension($file['ext']);
     if ($mimeType) {
         $response->headers->set('Content-Type', $mimeType);
     }
     return $response;
 }
開發者ID:robert-li-2015,項目名稱:EduSoho,代碼行數:19,代碼來源:LessonProcessorImpl.php

示例3: localMediaAction

 public function localMediaAction(Request $request, $id, $token)
 {
     $file = $this->getUploadFileService()->getFile($id);
     if (empty($file)) {
         throw $this->createNotFoundException();
     }
     if (!in_array($file["type"], array("audio", "video"))) {
         throw $this->createAccessDeniedException();
     }
     $token = $this->getTokenService()->verifyToken('local.media', $token);
     if ($token['userId'] != $this->getCurrentUser()->getId()) {
         throw $this->createAccessDeniedException();
     }
     $response = BinaryFileResponse::create($file['fullpath'], 200, array(), false);
     $response->trustXSendfileTypeHeader();
     $mimeType = FileToolkit::getMimeTypeByExtension($file['ext']);
     if ($mimeType) {
         $response->headers->set('Content-Type', $mimeType);
     }
     return $response;
 }
開發者ID:fujianguo,項目名稱:EduSoho,代碼行數:21,代碼來源:PlayerController.php


注:本文中的Topxia\Common\FileToolkit::getMimeTypeByExtension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。