2017-10-20 78 views
0

我有這樣廣東話上傳文件CSV數據庫主辦

function upload() { 

    $this->db->empty_table('area_proses'); 

    $data['error'] = ''; //initialize image upload error array to empty 

    $config['upload_path'] = './coba_upload/'; 
    $config['allowed_types'] = 'csv'; 
    $config['max_size'] = '20'; 

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

    $data['level'] = $this->session->userdata('level_id'); 
    $data['email'] = $this->session->userdata('email'); 
    $data['include'] = $this->load->view('/read/include','',TRUE); 
    $data['content'] = $this->load->view('/read/upload',$data,TRUE); 
    $this->load->view("admin/main",$data); 

    // If upload failed, display error 
    if (!$this->upload->do_upload()) { 
     $data['error'] = $this->upload->display_errors(); 
     //$this->load->view('/read/upload', $data); 
    } else { 
     $file_data = $this->upload->data(); 
     $file_path = './coba_upload/'.$file_data['file_name']; 

     if ($this->csvimport->get_array($file_path)) { 
      $csv_array = $this->csvimport->get_array($file_path); 
      foreach ($csv_array as $row) { 
       $insert_data = array(
        'id'=>$row['id'], 
        'area_proses'=>$row['area_proses'], 
        'sg1'=>$row['sg1'], 
        'sg2'=>$row['sg2'], 
        'sg3'=>$row['sg3'], 
        'avg'=>$row['avg'], 
        'fuzzy'=>$row['fuzzy'], 
       ); 
        $this->model->insert_csv($insert_data); 
       } 
       $this->session->set_flashdata('success', 'Csv Data Imported Succesfully'); 
       redirect(base_url().'area_proses'); 
        //echo "<pre>"; print_r($insert_data); 
     } else 
      $data['include'] = $this->load->view('/read/include','',TRUE); 
      $data['content'] = $this->load->view('/read/upload',$data,TRUE); 
      $this->load->view("admin/main",$data); 
    } 


} 

問題是,我可以上傳CSV文件插入到數據庫在本地主機(XAMPP),但是當我託管代碼,該代碼是不行的,只能刪除一個數據而不能讀取csv插入數據庫

你有解決方案嗎?

回答