嗨,我
正在尝试在 Codeigniter 中上传.ini文件,但 CI 向我显示错误,不允许使用此文件类型。
我尝试将其放入哑剧中.php但没有奏效:
$mimes = array('ini' => 'application/octet-stream')
我的代码是:
public function index()
{
$this->load->view('customer/upload/upload_ini', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'ini';
$this->load->library('upload', $config);
$this->upload->initialize($config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('customer/upload/upload_ini', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('customer/upload/upload_success', $data);
}
}
此解决方案可能适合您,但它会上传所有文件类型,无需任何扩展名检查,
$config['allowed_types'] = '*';
愿此链接对您有用。
希望它能帮助你:)