php - Uploading csv not working on Server Codeigniter -
this question has answer here:
- uploading csv codeigniter 5 answers
here code
function importcsv() { $data['addressbook'] = $this->csv_model->get_addressbook(); $data['error'] = ''; //initialize image upload error array empty $config['upload_path'] = './uploads/'; $config['allowed_types'] = 'csv'; $config['max_size'] = '1000'; $this->load->library('upload', $config); // if upload failed, display error if (!$this->upload->do_upload()) { $data['error'] = $this->upload->display_errors(); $this->load->view('csvindex', $data); } else { $file_data = $this->upload->data(); $file_path = './uploads/' . $file_data['file_name']; if ($this->csvimport->get_array($file_path)) { $csv_array = $this->csvimport->get_array($file_path); foreach($csv_array $row) { $insert_data = array( 'firstname' => $row['firstname'], 'lastname' => $row['lastname'], 'birthday' => $row['birthday'], 'email' => $row['email'], ); $this->csv_model->insert_csv($insert_data); } $this->session->set_flashdata('success', 'csv data imported succesfully'); redirect(base_url() . 'csv'); // echo "<pre>"; print_r($insert_data); } else $data['error'] = "error occured"; $this->load->view('csvindex', $data); } }
on localhost uploading working fine on server "the filetype attempting upload not allowed".
mysql privilege active file permission 755. tried changing permission 777 doesn't help.
the message server not allowed receive type of file. probabily need modify server configuration enable upload of csv files. (look @ configuration of localhost, since working)
Comments
Post a Comment