Advertisement
jamboljack

Upload Multiple Image

Oct 12th, 2017
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.36 KB | None | 0 0
  1. public function updatedata() {
  2.         $jam        = time();
  3.         $rtlh_id    = $this->input->post('id', 'true');
  4.        
  5.         for($i=1; $i<3; $i++) {            
  6.             // Property Image
  7.             if ($i === 1) {
  8.                 $config['upload_path']      = './img/foto/';
  9.             } else {
  10.                 $config['upload_path']      = './img/foto_rumah/';
  11.             }
  12.  
  13.             $config['file_name']        = 'Foto_'.$rtlh_id.'_'.$jam.'.jpg';
  14.             $config['allowed_types']    = 'gif|jpg|png|bmp|jpeg';
  15.             $config['max_size']         = '0';
  16.             $config['max_width']        = '0';
  17.             $config['max_height']       = '0';
  18.             $this->load->library('upload', $config);
  19.  
  20.             // Resize
  21.             $configThumb                    = array();
  22.             $configThumb['image_library']   = 'gd2';
  23.             $configThumb['source_image']    = '';
  24.             $configThumb['maintain_ratio']  = TRUE;
  25.             $configThumb['overwrite']       = TRUE;
  26.  
  27.             if ($i === 1) {
  28.                 $configThumb['width']           = 150;
  29.                 $configThumb['height']          = 200;
  30.             } else {
  31.                 $configThumb['width']           = 800;
  32.                 $configThumb['height']          = 500;
  33.             }
  34.             $this->load->library('image_lib');
  35.  
  36.             $upload = $this->upload->do_upload('foto'.$i);
  37.             if ($upload === FALSE) continue;
  38.             $upload_data = $this->upload->data();
  39.             $name_array[] = $upload_data['file_name'];
  40.  
  41.             //$uploadedFiles[$i] = $data;
  42.             //$upload_data = $this->upload->data();
  43.             //$data = $this->upload->data();
  44.             //$name_array[] = $upload_data['file_name'];
  45.  
  46.             if ($upload_data['is_image'] == 1) {
  47.                 $configThumb['source_image'] = $upload_data['full_path'];
  48.                 $this->image_lib->initialize($configThumb);
  49.                 $this->image_lib->resize();
  50.             }
  51.  
  52.             if ($i == 1) {
  53.                 // Update Foto Profil dan Data
  54.                 $this->rtlh_m->update_data($upload_data);
  55.             } else {
  56.                 // Update Foto Rumah
  57.                 $this->rtlh_m->update_data_rumah($upload_data);
  58.             }
  59.         }
  60.  
  61.         $response['status'] = 'success';
  62.         echo json_encode($response);
  63.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement