本文整理匯總了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'));
}
}