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


PHP FileToolkit::isImageFile方法代碼示例

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


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

示例1: approvalSubmitAction

 public function approvalSubmitAction(Request $request)
 {
     $user = $this->getCurrentUser();
     if ($request->getMethod() == 'POST') {
         $faceImg = $request->files->get('faceImg');
         $backImg = $request->files->get('backImg');
         if (!FileToolkit::isImageFile($backImg) || !FileToolkit::isImageFile($faceImg)) {
             return $this->createMessageResponse('error', '上傳圖片格式錯誤,請上傳jpg, bmp,gif, png格式的文件。');
         }
         $directory = $this->container->getParameter('topxia.upload.private_directory') . '/approval';
         $this->getUserService()->applyUserApproval($user['id'], $request->request->all(), $faceImg, $backImg, $directory);
         $this->setFlashMessage('success', '實名認證提交成功!');
         return $this->redirect($this->generateUrl('settings'));
     }
     return $this->render('TopxiaWebBundle:Settings:approval.html.twig', array());
 }
開發者ID:bqx619,項目名稱:edusoho_dev,代碼行數:16,代碼來源:SettingsController.php

示例2: consultUploadAction

 public function consultUploadAction(Request $request)
 {
     $fileId = $request->request->get('id');
     $objectFile = $this->getFileService()->getFileObject($fileId);
     if (!FileToolkit::isImageFile($objectFile)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $file = $this->getFileService()->getFile($fileId);
     $parsed = $this->getFileService()->parseFileUri($file["uri"]);
     $consult = $this->getSettingService()->get('consult', array());
     $consult['webchatURI'] = "{$this->container->getParameter('topxia.upload.public_url_path')}/" . $parsed["path"];
     $consult['webchatURI'] = ltrim($consult['webchatURI'], '/');
     $this->getSettingService()->set('consult', $consult);
     $this->getLogService()->info('system', 'update_settings', "更新微信二維碼", array('webchatURI' => $consult['webchatURI']));
     $response = array('path' => $consult['webchatURI'], 'url' => $this->container->get('templating.helper.assets')->getUrl($consult['webchatURI']));
     return $this->createJsonResponse($response);
 }
開發者ID:ccq18,項目名稱:EduSoho,代碼行數:17,代碼來源:SiteSettingController.php

示例3: consultUploadAction

 public function consultUploadAction(Request $request)
 {
     $file = $request->files->get('consult');
     if (!FileToolkit::isImageFile($file)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $filename = 'webchat.' . $file->getClientOriginalExtension();
     $directory = "{$this->container->getParameter('topxia.upload.public_directory')}/system";
     $file = $file->move($directory, $filename);
     $consult = $this->getSettingService()->get('consult', array());
     $consult['webchatURI'] = "{$this->container->getParameter('topxia.upload.public_url_path')}/system/{$filename}";
     $consult['webchatURI'] = ltrim($consult['webchatURI'], '/');
     $this->getSettingService()->set('consult', $consult);
     $this->getLogService()->info('system', 'update_settings', "更新微信二維碼", array('webchatURI' => $consult['webchatURI']));
     $response = array('path' => $consult['webchatURI'], 'url' => $this->container->get('templating.helper.assets')->getUrl($consult['webchatURI']));
     return new Response(json_encode($response));
 }
開發者ID:Loyalsoldier,項目名稱:8000wei-v2,代碼行數:17,代碼來源:SiteSettingController.php

示例4: mobilePictureUploadAction

 public function mobilePictureUploadAction(Request $request, $type)
 {
     $file = $request->files->get($type);
     if (!FileToolkit::isImageFile($file)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $filename = 'mobile_picture' . time() . '.' . $file->getClientOriginalExtension();
     $directory = "{$this->container->getParameter('topxia.upload.public_directory')}/system";
     $file = $file->move($directory, $filename);
     $mobile = $this->getSettingService()->get('mobile', array());
     $mobile[$type] = "{$this->container->getParameter('topxia.upload.public_url_path')}/system/{$filename}";
     $mobile[$type] = ltrim($mobile[$type], '/');
     $this->getSettingService()->set('mobile', $mobile);
     $this->getLogService()->info('system', 'update_settings', "更新網校{$type}圖片", array($type => $mobile[$type]));
     $response = array('path' => $mobile[$type], 'url' => $this->container->get('templating.helper.assets')->getUrl($mobile[$type]));
     return new Response(json_encode($response));
 }
開發者ID:ZHONG-GUO,項目名稱:EduSoho,代碼行數:17,代碼來源:MobileController.php

示例5: pictureAction

 public function pictureAction(Request $request, $id)
 {
     $course = $this->getCourseService()->tryManageCourse($id);
     if ($request->getMethod() == 'POST') {
         $file = $request->files->get('picture');
         if (!FileToolkit::isImageFile($file)) {
             return $this->createMessageResponse('error', '上傳圖片格式錯誤,請上傳jpg, gif, png格式的文件。');
         }
         $filenamePrefix = "course_{$course['id']}_";
         $hash = substr(md5($filenamePrefix . time()), -8);
         $ext = $file->getClientOriginalExtension();
         $filename = $filenamePrefix . $hash . '.' . $ext;
         $directory = $this->container->getParameter('topxia.upload.public_directory') . '/tmp';
         $file = $file->move($directory, $filename);
         $fileName = str_replace('.', '!', $file->getFilename());
         return $this->redirect($this->generateUrl('course_manage_picture_crop', array('id' => $course['id'], 'file' => $fileName)));
     }
     return $this->render('TopxiaWebBundle:CourseManage:picture.html.twig', array('course' => $course));
 }
開發者ID:styling,項目名稱:LeesPharm,代碼行數:19,代碼來源:CourseManageController.php

示例6: uploadAction

 public function uploadAction(Request $request)
 {
     list($groupCode, $type) = $this->tryUploadFile($request);
     if (!$this->isGroup($groupCode)) {
         return $this->createMessageResponse("error", "參數不正確");
     }
     $file = $request->files->get('file');
     if ($type == 'image') {
         if (!FileToolkit::isImageFile($file)) {
             throw new \RuntimeException("您上傳的不是圖片文件,請重新上傳。");
         }
     } else {
         throw new \RuntimeException("上傳類型不正確!");
     }
     $record = $this->getFileService()->uploadFile($groupCode, $file);
     $record['url'] = $this->get('topxia.twig.web_extension')->getFilePath($record['uri']);
     $request->getSession()->set("fileId", $record["id"]);
     return $this->createJsonResponse($record);
 }
開發者ID:ccq18,項目名稱:EduSoho,代碼行數:19,代碼來源:FileController.php

示例7: pictureAction

 public function pictureAction(Request $request, $id)
 {
     $gift = $this->getGiftService()->tryManageGift($id);
     if ($request->getMethod() == 'POST') {
         $reponse = array();
         $file = $request->files->get('picture');
         if (!FileToolkit::isImageFile($file)) {
             return $this->createMessageResponse('error', '上傳圖片格式錯誤,請上傳jpg, gif, png格式的文件。');
         }
         $filenamePrefix = "gift_{$gift['id']}_";
         $hash = substr(md5($filenamePrefix . time()), -8);
         $ext = $file->getClientOriginalExtension();
         $filename = $filenamePrefix . $hash . '.' . $ext;
         $directory = $this->container->getParameter('topxia.upload.public_directory') . '/tmp';
         $file = $file->move($directory, $filename);
         $fileName = str_replace('.', '!', $file->getFilename());
         $pictureFilePath = $this->container->getParameter('topxia.upload.public_directory') . '/tmp/' . $filename;
         $this->getGiftService()->changeGiftPicture($gift['id'], $pictureFilePath);
         return $this->createJsonResponse($pictureFilePath);
     }
     return $this->render('TopxiaAdminBundle:Gift:picture.html.twig', array('gift' => $gift));
 }
開發者ID:liugang19890719,項目名稱:www.zesow.com,代碼行數:22,代碼來源:GiftController.php

示例8: uploadAction

 public function uploadAction(Request $request)
 {
     try {
         $token = $request->query->get('token');
         $maker = new UploadToken();
         $token = $maker->parse($token);
         if (empty($token)) {
             throw new \RuntimeException("上傳授權碼已過期,請刷新頁麵後重試!");
         }
         $file = $request->files->get('upload');
         if ($token['type'] == 'image') {
             if (!FileToolkit::isImageFile($file)) {
                 throw new \RuntimeException("您上傳的不是圖片文件,請重新上傳。");
             }
         } elseif ($token['type'] == 'flash') {
             $errors = FileToolkit::validateFileExtension($file, 'swf');
             if (!empty($errors)) {
                 throw new \RuntimeException("您上傳的不是Flash文件,請重新上傳。");
             }
         } else {
             throw new \RuntimeException("上傳類型不正確!");
         }
         $record = $this->getFileService()->uploadFile($token['group'], $file);
         $funcNum = $request->query->get('CKEditorFuncNum');
         $url = $this->get('topxia.twig.web_extension')->getFilePath($record['uri']);
         if ($token['type'] == 'image') {
             $response = "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', function(){ this._.dialog.getParentEditor().insertHtml('<img src=\"{$url}\">'); this._.dialog.hide(); return false; });</script>";
         } else {
             $response = "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}');</script>";
         }
         return new Response($response);
     } catch (\Exception $e) {
         $message = $e->getMessage();
         $funcNum = $request->query->get('CKEditorFuncNum');
         $response = "<script type='text/javascript'>window.parent.CKEDITOR.tools.callFunction({$funcNum}, '', '{$message}');</script>";
         return new Response($response);
     }
 }
開發者ID:liugang19890719,項目名稱:www.zesow.com,代碼行數:38,代碼來源:EditorController.php

示例9: defaultCoursePictureAction

 public function defaultCoursePictureAction(Request $request)
 {
     $file = $request->files->get('picture');
     if (!FileToolkit::isImageFile($file)) {
         return $this->createMessageResponse('error', '上傳圖片格式錯誤,請上傳jpg, gif, png格式的文件。');
     }
     $filenamePrefix = "coursePicture";
     $hash = substr(md5($filenamePrefix . time()), -8);
     $ext = $file->getClientOriginalExtension();
     $filename = $filenamePrefix . $hash . '.' . $ext;
     $defaultSetting = $this->getSettingService()->get('default', array());
     $defaultSetting['defaultCoursePictureFileName'] = $filename;
     $this->getSettingService()->set("default", $defaultSetting);
     $directory = $this->container->getParameter('topxia.upload.public_directory') . '/tmp';
     $file = $file->move($directory, $filename);
     $pictureFilePath = $directory . '/' . $filename;
     $imagine = new Imagine();
     $image = $imagine->open($pictureFilePath);
     $naturalSize = $image->getSize();
     $scaledSize = $naturalSize->widen(480)->heighten(270);
     $pictureUrl = $this->container->getParameter('topxia.upload.public_url_path') . '/tmp/' . $filename;
     return $this->render('TopxiaAdminBundle:System:default-course-picture-crop.html.twig', array('pictureUrl' => $pictureUrl, 'naturalSize' => $naturalSize, 'scaledSize' => $scaledSize));
 }
開發者ID:styling,項目名稱:LeesPharm,代碼行數:23,代碼來源:SystemDefaultSettingController.php

示例10: uploadAvatar

 public function uploadAvatar()
 {
     $groupCode = 'tmp';
     $user = $this->controller->getUserByToken($this->request);
     if (empty($user)) {
         return $this->createErrorResponse('not_login', "您尚未登錄!");
     }
     $file = $this->request->files->get('file');
     if (empty($file)) {
         return $this->createErrorResponse('error', "沒有選擇上傳文件!");
     }
     if (!FileToolkit::isImageFile($file)) {
         return $this->createErrorResponse('error', "您上傳的不是圖片文件,請重新上傳。");
     }
     $record = $this->getFileService()->uploadFile($groupCode, $file);
     if (empty($record)) {
         return $this->createErrorResponse('error', "上傳失敗 ~請重新嘗試!");
     }
     $host = $this->request->getSchemeAndHttpHost();
     $record['url'] = $host . $this->controller->get('topxia.twig.web_extension')->getFilePath($record['uri']);
     $record['createdTime'] = date('c', $record['createdTime']);
     unset($record['uri']);
     return $record;
 }
開發者ID:nanyi,項目名稱:EduSoho,代碼行數:24,代碼來源:UserProcessorImpl.php

示例11: avatarAction

 public function avatarAction(Request $request, $id)
 {
     if (false === $this->get('security.context')->isGranted('ROLE_SUPER_ADMIN')) {
         throw $this->createAccessDeniedException();
     }
     $user = $this->getUserService()->getUser($id);
     $form = $this->createFormBuilder()->add('avatar', 'file')->getForm();
     if ($request->getMethod() == 'POST') {
         $form->bind($request);
         if ($form->isValid()) {
             $data = $form->getData();
             $file = $data['avatar'];
             if (!FileToolkit::isImageFile($file)) {
                 return $this->createMessageResponse('error', '上傳圖片格式錯誤,請上傳jpg, gif, png格式的文件。');
             }
             $filenamePrefix = "user_{$user['id']}_";
             $hash = substr(md5($filenamePrefix . time()), -8);
             $ext = $file->getClientOriginalExtension();
             $filename = $filenamePrefix . $hash . '.' . $ext;
             $directory = $this->container->getParameter('topxia.upload.public_directory') . '/tmp';
             $file = $file->move($directory, $filename);
             $fileName = str_replace('.', '!', $file->getFilename());
             $avatarData = $this->avatar_2($id, $fileName);
             return $this->render('TopxiaAdminBundle:User:user-avatar-crop-modal.html.twig', array('user' => $user, 'filename' => $fileName, 'pictureUrl' => $avatarData['pictureUrl'], 'naturalSize' => $avatarData['naturalSize'], 'scaledSize' => $avatarData['scaledSize']));
         }
     }
     $hasPartnerAuth = $this->getAuthService()->hasPartnerAuth();
     if ($hasPartnerAuth) {
         $partnerAvatar = $this->getAuthService()->getPartnerAvatar($user['id'], 'big');
     } else {
         $partnerAvatar = null;
     }
     return $this->render('TopxiaAdminBundle:User:user-avatar-modal.html.twig', array('form' => $form->createView(), 'user' => $this->getUserService()->getUser($user['id']), 'partnerAvatar' => $partnerAvatar));
 }
開發者ID:styling,項目名稱:LeesPharm,代碼行數:34,代碼來源:UserController.php

示例12: videoEmbedWatermarkUploadAction

 public function videoEmbedWatermarkUploadAction(Request $request)
 {
     $file = $request->files->get('watermark');
     if (!FileToolkit::isImageFile($file)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $filename = 'watermarkembed_' . time() . '.' . $file->getClientOriginalExtension();
     $directory = "{$this->container->getParameter('topxia.upload.public_directory')}/system";
     $file = $file->move($directory, $filename);
     $path = "system/{$filename}";
     $originFileInfo = getimagesize($file);
     $filePath = $this->container->getParameter('topxia.upload.public_directory') . "/" . $path;
     $imagine = new Imagine();
     $rawImage = $imagine->open($filePath);
     $pathinfo = pathinfo($filePath);
     $specification['240'] = 20;
     $specification['360'] = 30;
     $specification['480'] = 40;
     $specification['720'] = 60;
     $specification['1080'] = 90;
     foreach ($specification as $key => $value) {
         $width = $originFileInfo[0] * $value / $originFileInfo[1];
         $specialImage = $rawImage->copy();
         $specialImage->resize(new Box($width, $value));
         $filePath = "{$pathinfo['dirname']}/{$pathinfo['filename']}-{$key}.{$pathinfo['extension']}";
         $specialImage->save($filePath);
     }
     $response = array('path' => $path, 'url' => $this->get('topxia.twig.web_extension')->getFileUrl($path));
     return new Response(json_encode($response));
 }
開發者ID:kevan,項目名稱:EduSoho,代碼行數:30,代碼來源:CloudSettingController.php

示例13: faviconUploadAction

 public function faviconUploadAction(Request $request)
 {
     $fileId = $request->request->get('id');
     $objectFile = $this->getFileService()->getFileObject($fileId);
     if (!FileToolkit::isImageFile($objectFile)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $file = $this->getFileService()->getFile($fileId);
     $parsed = $this->getFileService()->parseFileUri($file["uri"]);
     $site = $this->getSettingService()->get('site', array());
     $oldFileId = empty($site['favicon_file_id']) ? null : $site['favicon_file_id'];
     $site['favicon_file_id'] = $fileId;
     $site['favicon'] = "{$this->container->getParameter('topxia.upload.public_url_path')}/" . $parsed["path"];
     $site['favicon'] = ltrim($site['favicon'], '/');
     $this->getSettingService()->set('site', $site);
     if ($oldFileId) {
         $this->getFileService()->deleteFile($oldFileId);
     }
     $this->getLogService()->info('system', 'update_settings', "更新瀏覽器圖標", array('favicon' => $site['favicon']));
     $response = array('path' => $site['favicon'], 'url' => $this->container->get('templating.helper.assets')->getUrl($site['favicon']));
     return $this->createJsonResponse($response);
 }
開發者ID:jonesgithub,項目名稱:EduSoho,代碼行數:22,代碼來源:SettingController.php

示例14: logoUploadAction

 public function logoUploadAction(Request $request)
 {
     $fileId = $request->request->get('id');
     $objectFile = $this->getFileService()->getFileObject($fileId);
     if (!FileToolkit::isImageFile($objectFile)) {
         throw $this->createAccessDeniedException('圖片格式不正確!');
     }
     $file = $this->getFileService()->getFile($fileId);
     $parsed = $this->getFileService()->parseFileUri($file["uri"]);
     $response = array('path' => '/files/system/2015/11-15/112251b78d20251961.jpg', 'url' => '/files/system/2015/11-15/112251b78d20251961.jpg');
     return $this->createJsonResponse($response);
 }
開發者ID:latticet,項目名稱:EduSoho_jb51,代碼行數:12,代碼來源:HomeworkController.php

示例15: array

    $status = ServiceKernel::instance()->createService('User.UserService')->verifyPassword($user_id, $current_password);
    if ($status) {
        $result = ServiceKernel::instance()->createService('User.UserService')->changePassword($user_id, $new_password);
    } else {
        $result = false;
    }
    return array('success' => $result);
});
//上傳頭像
$api->post('/avatar/post', function (Request $request) {
    $user = getCurrentUser();
    $userId = $user['id'];
    //上傳
    $groupCode = 'user';
    $file = $request->files->get('file');
    if (!FileToolkit::isImageFile($file)) {
        throw new \RuntimeException("您上傳的不是圖片文件,請重新上傳。");
    }
    $FileService = ServiceKernel::instance()->createService('Content.FileService');
    $record = $FileService->uploadFile($groupCode, $file);
    $parsed = $FileService->parseFileUri($record['uri']);
    $imgInfo = getimagesize($parsed['fullpath']);
    //切圖
    $options = array();
    $options['x'] = $request->request->get('x', 0);
    $options['y'] = $request->request->get('x', 71);
    $options['x2'] = $request->request->get('x', 180);
    $options['y2'] = $request->request->get('x', 251);
    $options['w'] = $request->request->get('x', 180);
    $options['h'] = $request->request->get('x', 180);
    $options['width'] = $imgInfo[0];
開發者ID:latticet,項目名稱:EduSoho_jb51,代碼行數:31,代碼來源:me.php


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