本文整理汇总了PHP中SimpleImage::uploadImage方法的典型用法代码示例。如果您正苦于以下问题:PHP SimpleImage::uploadImage方法的具体用法?PHP SimpleImage::uploadImage怎么用?PHP SimpleImage::uploadImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleImage
的用法示例。
在下文中一共展示了SimpleImage::uploadImage方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: changeProfilePicture
public function changeProfilePicture()
{
if (isset($this->session->userdata['user_id']) && !empty($_FILES) && $_FILES['user_img']['size'] > 0 && $_FILES['user_img']['error'] == 0) {
$model = new Common_model();
$user_id = $this->session->userdata['user_id'];
$user_record = $model->fetchSelectedData('user_profile_picture, user_username', TABLE_USERS, array('user_id' => $user_id));
$user_record = $user_record[0];
$redirect_url = base_url('my-account');
if ($this->input->post('next')) {
$redirect_url = $this->input->post('next');
}
$source = $_FILES['user_img']['tmp_name'];
$destination = USER_IMG_PATH . "/" . getEncryptedString($user_id . time()) . ".jpg";
$this->load->library('SimpleImage');
$simpleImage = new SimpleImage();
$simpleImage->uploadImage($source, $destination, USER_IMG_WIDTH, USER_IMG_HEIGHT);
// removing older picture
@unlink($user_record['user_profile_picture']);
$model->updateData(TABLE_USERS, array('user_profile_picture' => $destination), array('user_id' => $user_id));
$this->session->set_flashdata('success', '<strong>Success!</strong> Your profile picture has been changed');
// updating redis keys now
$this->redis_functions->set_user_profile_data($user_record['user_username']);
redirect($redirect_url);
} else {
redirect(base_url('login'));
}
}