2017-10-13 59 views
0

嗨,大家好,我有上傳類codeigniter的問題..上傳不工作,沒有輸入到數據庫..我認爲在功能,如果不工作,但如何?在我的其他代碼我通常使用這個代碼總是工作..上傳類codeigniter不工作,並沒有輸入到數據庫

這個功能我覺得不行

if ($this->upload->do_upload('cv')) { 
    $data = $this->upload->data(); 
    $cv = $this->createImageOne($data); 
} 

if ($this->form_validation->run() === TRUE) { 

     $nik = $this->input->post('nik', true); 
     $employee_name = trim(addslashes($this->input->post('employee_name', true))); 
     $email = trim(addslashes($this->input->post('email', true))); 
     $sex = trim(addslashes($this->input->post('sex', true))); 
     $bornplace = trim(addslashes($this->input->post('bornplace', true))); 
     $borndate = trim(date('Y-m-d', strtotime($this->input->post('borndate', true)))); 
     $address = trim(addslashes($this->input->post('address', true))); 
     $tlp = trim(addslashes($this->input->post('tlp', true))); 
     $education = trim(addslashes($this->input->post('education', true))); 
     $position = trim(addslashes($this->input->post('position', true))); 
     $vendor = trim(addslashes($this->input->post('vendor', true))); 
     $gapok = trim(addslashes($this->input->post('gapok', true))); 
     $start_date = trim(date('Y-m-d', strtotime($this->input->post('start_date', true)))); 
     $end_date = trim(date('Y-m-d', strtotime($this->input->post('end_date', true)))); 
     $status = trim(addslashes($this->input->post('status', true))); 

     $this->load->library('image_lib'); 
     $config['upload_path'] = $this->config->item('upload_temp'); 

     $config['allowed_types'] = '*'; 
     $config['max_size'] = '1000000'; 
     $config['max_width'] = '2048'; 
     $config['max_height'] = '2048'; 

     $this->load->library('upload', $config); 


     $cv = ''; 
     $foto = ''; 



     if ($this->upload->do_upload('cv')) { 
      $data = $this->upload->data(); 
      $cv = $this->createImageOne($data); 
     } 



     if ($this->upload->do_upload('foto')) { 
      $datafour = $this->upload->data(); 
      $foto = $this->createImageFour($datafour); 
     } 

     $this->Mkaryawan->insert_karyawan($nik, $employee_name, $email, $sex, $bornplace, $borndate, $address, $tlp, $education, $position, $vendor, $gapok, $start_date, $end_date, $status, $cv, $foto); 


    } 

回答

0

您可以刪除下面的代碼行。至於如果文件上傳的作品完美,那麼你可以將更多的驗證:

$this->load->library('image_lib');

$config['max_size'] = '1000000'; $config['max_width'] = '2048'; $config['max_height'] = '2048';

作爲參考,你可以按照this link在笨上傳單/多文件

+0

我不噸得到它形式的鏈接,也許是真的我的代碼不能工作因爲數據庫?由於數據庫而導致 –

+0

?我沒有明白你的觀點。 – user2005235

相關問題