when I run it on localhost my csv uploading file is completely fine but when I host it in the web it will get some error. Its redirecting me to the csvindex.php I already check the columns in csv file
Here's my importcsv():
function importcsv($org, $course) {
$data['addressbook'] = $this->users_model->get_addressbook();
$data['error'] = ''; //initialize image upload error array to 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 as $row) {
$insert_data = array(
'student_fname'=>$row['student_fname'],
'student_lname'=>$row['student_lname'],
'student_course'=>$row['student_course'],
'email'=>$row['email'],
'student_dept'=>$row['student_dept'],
'student_year'=>$row['student_year'],
'student_img'=>$row['student_img'],
'contact'=>$row['contact'],
'password'=>md5($row['password'])
);
$this->users_model->insert_csv($insert_data);
}
redirect('admin/colleges/show_students/'.$org.'/'.$course);
} else
$data['error'] = "Error occured";
$this->load->view('csvindex', $data);
}
}
Here's my get_addressbook():
function get_addressbook() {
$query = $this->db->get('tbl_students');
if ($query->num_rows() > 0) {
return $query->result_array();
} else {
return FALSE;
}
}
Can someone help me with this please?
Check $file_path,the upload folder path in your server and check your upload folder permission – Sharmistha Das 2 hours ago
The error seems to be that your upload path either does not exist or does not have the right permissions.
Best way to solve it is to go in via FTP or SSH to create the "uploads" folder in your codeigniter root.