當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。