2014-03-27 129 views
0

我喜歡上傳一個文件的形式,它包含一些文本框和一個文件上傳按鈕, 如何在codeigniter中, 當我在單獨做我可以但隨着文件上傳我不能上傳文件數據和文本框,單選按鈕值到數據庫

function upload() 
{ 
    $config['upload_path'] = './uploads/'; 
    $config['allowed_types'] = 'gif|jpg|png|txt|pdf|doc|docx'; 
    $config['max_size'] = '1024'; 
    $config['max_width'] = '1024'; 
    $config['max_height'] = '768'; 

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

    if (! $this->upload->do_upload()) 
    { 
     $error = array('error' => $this->upload->display_errors()); 

     $this->load->view('js_home', $error); 
    } 
    else 
    { 
     $data = array('upload_data' => $this->upload->data(),'phone' =>$this->input->post('phone'),'email' =>$this->input->post('email'),'password' =>$this->input->post('password')); 
     $this->jobseeker->storefile($data); 
     $this->load->view('samples/upload_success', $data);// after uploaded the file 
    } 
} 
+0

有任何錯誤去做 –

+0

是否要將文件名存儲在數據庫中 –

+0

是什麼問題?上傳完成後,您只需更新/插入數據庫。 –

回答

1

試試這個

if (! $this->upload->do_upload('file')) 
    { 
     $error = array('error' => $this->upload->display_errors()); 

     $this->load->view('js_home', $error); 
    } 
    else 
    { 
$fInfo = $this->upload->data(); 

     $data = array('upload_data' => $fInfo['file_name'],'phone' =>$this->input->post('phone'),'email' =>$this->input->post('email'),'password' =>$this->input->post('password')); 
     $this->jobseeker->storefile($data); 
     $this->load->view('samples/upload_success', $data);// after uploaded the file 
    } 

鑑於<input type='file' name='file'>

+0

非常棒Dude它工作正常,謝謝你.. – balaji

相關問題