Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $jam = time();
- $username = $this->session->userdata('username');
- $config['file_name'] = 'Avatar_' . $username . '_' . $jam . '.jpg';
- $config['upload_path'] = './img/icon/';
- $config['allowed_types'] = 'jpg|png|gif|jpeg';
- $config['overwrite'] = true;
- $config['max_size'] = 0;
- $this->load->library('upload');
- $this->upload->initialize($config);
- // Resize
- $configThumb = array();
- $configThumb['image_library'] = 'gd2';
- $configThumb['source_image'] = '';
- $configThumb['maintain_ratio'] = true;
- $configThumb['overwrite'] = true;
- $configThumb['width'] = 150;
- $configThumb['height'] = 150;
- $this->load->library('image_lib');
- if (!$this->upload->do_upload('foto')) {
- $response['status'] = 'error';
- } else {
- $upload = $this->upload->do_upload('foto');
- $upload_data = $this->upload->data();
- $name_array[] = $upload_data['file_name'];
- $configThumb['source_image'] = $upload_data['full_path'];
- $this->image_lib->initialize($configThumb);
- $this->image_lib->resize();
- // SImpan Data
- $data = array(
- 'user_avatar' => $this->upload->file_name,
- );
- $this->db->insert('pasar_users', $data);
- $response['status'] = 'success';
- }
- echo json_encode($response);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement