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


PHP FileHandler::tempFolder方法代码示例

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


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

示例1: action_edit

 public function action_edit()
 {
     $lUserData = Input::post('user', null);
     $lAvatar = Input::post('avatar', null);
     $lDeleteAvatar = Input::post('delete_avatar', null);
     if (empty($lUserData)) {
         die(json_encode(['status' => 'error', 'message' => 'Empty data for updating user'], JSON_UNESCAPED_UNICODE));
     }
     $lIsOwner = $lUserData['username'] == $this->current_user['username'];
     if ((empty($lUserData['username']) || !$lIsOwner) && !$this->is_admin) {
         die(json_encode(['status' => 'error', 'message' => 'Access denied'], JSON_UNESCAPED_UNICODE));
     }
     $lUserName = $lUserData['username'];
     unset($lUserData['username']);
     try {
         DB::start_transaction();
         $lOldData = Auth::get_profile_fields();
         if (!empty($lAvatar)) {
             $lNewAvatar = FileHandler::prepareFiles($lAvatar, FileHandler::tempFolder());
             foreach ($lNewAvatar as $lVal) {
                 $lUserData['avatar_id'] = Model_Avatars::add(['file_name' => $lVal]);
                 break;
             }
             if (!empty($lOldData['avatar_id'])) {
                 $lToDeleteAvatar = Model_Avatars::getById($lOldData['avatar_id']);
                 Model_Avatars::delete($lOldData['avatar_id']);
             }
         }
         if (!empty($lDeleteAvatar) && empty($lAvatar)) {
             $lOldAvatar = Model_Avatars::getById($lOldData['avatar_id']);
             foreach ($lDeleteAvatar as $lVal) {
                 if ($lVal != $lOldData['avatar_id']) {
                     break;
                 }
                 $lToDeleteAvatar = $lOldAvatar;
                 Model_Avatars::delete($lVal);
                 $lUserData['avatar_id'] = '';
                 break;
             }
         }
         $lResult = Auth::update_user($lUserData, $lUserName);
         if (!empty($lNewAvatar)) {
             FileHandler::moveFiles($lNewAvatar, FileHandler::tempFolder(), FileHandler::AVATAR_FOLDER);
         }
         if (!empty($lToDeleteAvatar)) {
             FileHandler::deleteFiles([FileHandler::AVATAR_FOLDER . $lToDeleteAvatar['file_name']]);
         }
         DB::commit_transaction();
     } catch (Exception $e) {
         DB::rollback_transaction();
         die(json_encode(['status' => 'error', 'message' => 'Error ' . $e], JSON_UNESCAPED_UNICODE));
     }
     if ($lResult) {
         die(json_encode(['status' => 'ok'], JSON_UNESCAPED_UNICODE));
     }
     die(json_encode(['status' => 'error', 'message' => 'Fields not were updated'], JSON_UNESCAPED_UNICODE));
 }
开发者ID:FTTA,项目名称:devels,代码行数:57,代码来源:Users.php


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