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


PHP BuckysUser::updateUserProfileThumbnail方法代码示例

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


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

示例1: changeProfileImageAction

 public function changeProfileImageAction()
 {
     global $TNB_GLOBALS;
     $data = $_POST;
     $token = isset($data['TOKEN']) ? trim($data['TOKEN']) : null;
     if (!$token) {
         return ['STATUS_CODE' => STATUS_CODE_BAD_REQUEST, 'DATA' => buckys_api_get_error_result('Api token should not be blank')];
     }
     if (!($userID = BuckysUsersToken::checkTokenValidity($token, "api"))) {
         return ['STATUS_CODE' => STATUS_CODE_UNAUTHORIZED, 'DATA' => buckys_api_get_error_result('Api token is not valid.')];
     }
     //Upload photo if it is image type
     $tempFile = $_FILES['image']['tmp_name'];
     $targetPath = DIR_FS_PHOTO . "tmp";
     if (!is_dir($targetPath)) {
         mkdir($targetPath, 0777);
         //Create Index file
         $fp = fopen($targetPath . "/index.html", "w");
         fclose($fp);
     }
     // Validate the file type
     $fileParts = pathinfo($_FILES['image']['name']);
     //Check the file extension
     if (in_array(strtolower($fileParts['extension']), $TNB_GLOBALS['imageTypes'])) {
         //Check Image Size
         list($width, $height, $type, $attr) = getimagesize($tempFile);
         //Check Image Type
         if (!in_array($type, [IMAGETYPE_GIF, IMAGETYPE_JPEG, IMAGETYPE_JPEG2000, IMAGETYPE_PNG])) {
             return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_INVALID_PHOTO_TYPE)];
         }
         if ($width * $height > MAX_IMAGE_WIDTH * MAX_IMAGE_HEIGHT) {
             return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_PHOTO_MAX_SIZE_ERROR)];
         } else {
             $targetFileName = md5(uniqid()) . "." . $fileParts['extension'];
             $targetFile = $targetPath . '/' . $targetFileName;
             move_uploaded_file($tempFile, $targetFile);
             $data['file'] = $targetFileName;
         }
     } else {
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result(MSG_INVALID_PHOTO_TYPE)];
     }
     if (BuckysUser::updateUserProfileThumbnail($userID, $data['file'])) {
         //Success
         $message = buckys_get_pure_messages();
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => ['STATUS' => 'SUCCESS', 'MESSAGE' => $message]];
     } else {
         $error = buckys_get_pure_messages();
         return ['STATUS_CODE' => STATUS_CODE_OK, 'DATA' => buckys_api_get_error_result($error)];
     }
 }
开发者ID:HAPwebsite,项目名称:Social-Network-Website,代码行数:50,代码来源:postApi.php


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