本文整理匯總了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;
}
示例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;
}
示例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;
}