在上传CI .ini文件(uploading .ini files in CI)

2019-11-02 15:22发布

尝试上传.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文件中的任何改变?

或者是笨的上传库不允许上传.ini文件?

需要建议来解决这个问题。

Answer 1:

你忘了把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;
    }


Answer 2:

我得到这个问题solved.In配置/ mimes.php修改$哑剧阵列

     $mimes = array('ini' => 'application/octet-stream')

如果有任何人知道如何解决这个问题,而无需修改核心文件,* 请不要评论。 *



文章来源: uploading .ini files in CI