嗨,我有一个本地主机的代码,完全正常。
function importcsv_attendance() {
$data['addressbook'] = $this->CSVimportModule_Model->get_addressbook_att();
$data['error'] = '';
//initialize image upload error array to empty
$config['upload_path'] = './uploads/csv/';
$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();
$data['content_view'] = 'CSVimportModule/attendance';
$this->templates->admin_template($data);
} else {
$file_data = $this->upload->data();
$file_path = './uploads/csv/'.$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_NUM' => $row['ID_NUM'],
'DATE' => $row['DATE'],
'TIME_IN' => $row['TIME_IN'],
'TIME_OUT' => $row['TIME_OUT'],
'BREAK_IN' => $row['BREAK_IN'],
'BREAK_OUT' => $row['BREAK_OUT'],
'TOTAL_TIME'=> $row['TOTAL_TIME'],
);
$this->CSVimportModule_Model->insert_csv_att($insert_data);
}
$this->session->set_flashdata('success', 'CSV Data Imported Succesfully!');
redirect(base_url().'CSVimportModule/attendance');
} else
$data['error'] = "Error occured";
$data['content_view'] = 'CSVimportModule/attendance';
$this->templates->admin_template($data);
}
}
但是当我将代码上传到服务器时,我遇到了这个错误
The upload path does not appear to be valid.
。服务器是linux。我已经检查过是否有要上传的文件夹。有一个现有的文件夹,但是,我仍然有这个错误。我也尝试将整个网址放在文件路径上,但仍然是同样的错误。
答案 0 :(得分:0)
试试这个: 如果你正在使用.htaccess,那么在.htaccess中添加该文件夹。您的.htaccess文件看起来像
RewriteEngine on
Rewritebase /
RewriteCond $1 !^(index\.php|uploads|robots\.txt)
RewriteRule ^(.*)$ index.php/$1 [L]
"上传"是您上传文件等的文件夹。