本文整理汇总了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;
}