我有一个codeigniter项目,我部署到pagodabox,问题是它有一个文件上传表单,应该上传csv文件但不知何故我得到一个错误,说不允许文件类型。然而,它在我的本地wamp服务器上工作。
任何帮助将不胜感激。这是我的代码
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
类Uploadfile扩展了CI_Controller {
public function __construct()
{
parent::__construct();
//Do your magic here
$this->load->library('csvreader');
}
function upload() {
$session_data = $this->session->userdata('logged_in');
$current_user_name = $session_data['username'];
$config = array('upload_path' => 'application/uploads',
'max_size' => '0',
'allowed_types' => 'csv',
'file_name' => $current_user_name,
'overwrite' => true
);
$this->load->library('upload', $config);
$upload_field_name = 'csvfile';
if ( ! $this->upload->do_upload($upload_field_name)){
$error = array('error' => $this->upload->display_errors());
$this->load->view('upload_error', $error);
var_dump('$upload_field_name');
}
else {
$csvfile = array('csvfile' => $this->upload->data($upload_field_name));
$csvdata = $this->csvreader->parse_file($csvfile['csvfile']['full_path']);
$data['jsondata'] = json_encode($csvdata);
$this->load->view('dashboard', $data);
}
}
} ?&GT;
答案 0 :(得分:0)
您是否在Boxfile中指定此文件夹是可写的:
web1
...
shared_writable_dirs:
- /application/uploads/