Mysql
 sql >> Database >  >> RDS >> Mysql

csv caricato non funziona

Prova questo -

public function upload{

 $config['upload_path'] = APPPATH.'/assets/upload/';
$config['allowed_types'] = 'csv';
$config['max_size']  = '5000';
$replace='"';

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

if ( ! $this->upload->do_upload('file_name'))
{
    $error=array('error' => $this->upload->display_errors());
    $this->session->set_flashdata('msg_excel','Choose a .csv file to upload'); 
    redirect(base_url().'admin/advertisement/adv');

}
else
{  
   $data=array('upload_data' => $this->upload->data());
  $userfile=$data['upload_data']['full_path'];  // file name
  $upload_data=$this->upload->data(); 
  $csv_file = fopen($userfile, "r");
  // it will read csv file and convert into array
   while (($emapData = fgetcsv($csv_file, 10000, ",")) !== FALSE) 
     {
        echo "<pre>";
        print_r($emapData);
     }
  fclose($file);
}