emprit

multiple_uploads

Dec 11th, 2012
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.26 KB | None | 0 0
  1.     function tambahkelengkapan(){
  2.         $config['upload_path']      = realpath('kelengkapan_dokumen');
  3.         $config['allowed_types']    = 'gif|jpg|jpeg|jpe|png|pdf';
  4.  
  5.         $this->load->library('upload');
  6.         $no = $this->input->post('no_urut');
  7.    
  8.             // upload              
  9.             foreach ($_FILES as $key => $value)
  10.             {
  11.                 if (!empty($key['name']))
  12.                 {
  13.                     $filename = 'GE'.$no.'_name_'.mt_rand();
  14.                     $config['file_name']    = $filename;
  15.  
  16.                     $this->upload->initialize($config);
  17.  
  18.                     if (!$this->upload->do_upload($key))   
  19.                     {
  20.                         $errors = $this->upload->display_errors();
  21.                     }
  22.                     else
  23.                     {
  24.                         $data_upload[$key] = $filename;
  25.                     }
  26.             }
  27.                         }
  28.            
  29.            
  30.     // database
  31.         $query          = $this->db->where('type !=', '0')->get('form');
  32.         $query_result   = $query->result();
  33.         $insert_data = array('no_urut' => $this->input->post('no_urut'));
  34.  
  35.    // fields
  36.         foreach($query_result as $row)
  37.         {
  38.              $insert_data[$row->nama] = $this->input->post($row->nama);      
  39.         }
  40.  
  41.         $insert_data = array_merge($insert_data, $data_upload);
  42.          echo '<pre>';var_dump($insert_data);die('</pre>');
  43.         $insert = $this->db->insert('penilaian', $insert_data);
  44.  
  45.     return $insert ? TRUE : FALSE;
  46.    }
Advertisement
Add Comment
Please, Sign In to add comment