尝试上传.ini文件时出现以下错误
“不允许您尝试上传的文件类型。”
以下是上传文件的功能
private function _upload_config_file() {
$config['upload_path'] = APPPATH . 'config/ini/';
$config['allowed_types'] = 'ini';
$config['max_size'] = '2000000';
$this->load->library('upload', $config);
if ($this->upload->do_upload()) {
$this->upload_status = 'File uploaded succesfully !';
return true;
} else {
$this->upload_status = $this->upload->display_errors();
return false;
}
}
在视图中
$upload_file_attr = array(
'name' => 'userfile',
'id' => 'userfile',
'disabled' => 'disabled'
);
echo form_open_multipart('sys_setting', $form_sys_setting_multi);
echo form_label('Configure Manually' . form_checkbox($upload_checkbox, '', FALSE, $js_checkbox));
echo form_button($download_button);
echo form_upload($upload_file_attr);
echo form_reset($upload_reset);
echo form_submit($upload_submit);
echo form_close();
在php.ini中是否有任何更改用于上传.ini文件?
或者是codeigniter的上传库是否不允许上传.ini文件?
需要建议来解决这个问题。
答案 0 :(得分:0)
你忘了把field_name
尝试添加此内容:
if ($this->upload->do_upload('userfile')) { //parameter should the your input file name attribute
$this->upload_status = 'File uploaded succesfully !';
return true;
} else {
$this->upload_status = $this->upload->display_errors();
return false;
}
答案 1 :(得分:0)
我解决了这个问题。在config / mimes.php中修改了$ mimes数组
$mimes = array('ini' => 'application/octet-stream')
如果有人知道如何解决此问题而不修改核心文件,* 请发表评论。 *