Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function updatedata() {
- $jam = time();
- $rtlh_id = $this->input->post('id', 'true');
- for($i=1; $i<3; $i++) {
- // Property Image
- if ($i === 1) {
- $config['upload_path'] = './img/foto/';
- } else {
- $config['upload_path'] = './img/foto_rumah/';
- }
- $config['file_name'] = 'Foto_'.$rtlh_id.'_'.$jam.'.jpg';
- $config['allowed_types'] = 'gif|jpg|png|bmp|jpeg';
- $config['max_size'] = '0';
- $config['max_width'] = '0';
- $config['max_height'] = '0';
- $this->load->library('upload', $config);
- // Resize
- $configThumb = array();
- $configThumb['image_library'] = 'gd2';
- $configThumb['source_image'] = '';
- $configThumb['maintain_ratio'] = TRUE;
- $configThumb['overwrite'] = TRUE;
- if ($i === 1) {
- $configThumb['width'] = 150;
- $configThumb['height'] = 200;
- } else {
- $configThumb['width'] = 800;
- $configThumb['height'] = 500;
- }
- $this->load->library('image_lib');
- $upload = $this->upload->do_upload('foto'.$i);
- if ($upload === FALSE) continue;
- $upload_data = $this->upload->data();
- $name_array[] = $upload_data['file_name'];
- //$uploadedFiles[$i] = $data;
- //$upload_data = $this->upload->data();
- //$data = $this->upload->data();
- //$name_array[] = $upload_data['file_name'];
- if ($upload_data['is_image'] == 1) {
- $configThumb['source_image'] = $upload_data['full_path'];
- $this->image_lib->initialize($configThumb);
- $this->image_lib->resize();
- }
- if ($i == 1) {
- // Update Foto Profil dan Data
- $this->rtlh_m->update_data($upload_data);
- } else {
- // Update Foto Rumah
- $this->rtlh_m->update_data_rumah($upload_data);
- }
- }
- $response['status'] = 'success';
- echo json_encode($response);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement