Codeigniter模块化HMVC扩展-无法上传文件



我在通过表单上传文件时遇到问题。每次尝试时,我都会收到错误"文件类型不允许"。我使用HMVC模块化扩展,我的控制器扩展了MX_Controller。

我已经尝试从表单视图中使用$var_dump($_FILES),结果很好,但当我尝试在控制器中使用方法do_upload()时,它不起作用。

有人知道吗?这是控制器:

Class Store_data extends MX_Controller

function __construct()
{
    parent::__construct();
}
function upload_pic()
{
    //$data['item_id'] = $item_id;
    $template = "bootstrap_theme";
    //$current_url = current_url();
    //$data['form_location'] = $current_url;
    $data['view_file'] = "upload_pic";
    $this->load->module('template');
    $this->template->$template($data);
}
function do_upload()
{
    //var_dump($_FILES);
    $config['upload_path'] = './images/';
    $config['allowed_types'] = 'gif|jpg|png';
    $config['max_size'] = '10000';
    $config['max_width']  = '4024';
    $config['max_height']  = '4768';
    $this->load->library('upload', $config);
    $this->upload->overwrite = true;
    $this->upload->initialize($config);
    if ( ! $this->upload->do_upload())
    {
        $data['error'] = $this->upload->display_errors();
        $template = "bootstrap_theme";
        $data['view_file'] = "upload_pic";
        $this->load->module('template');
        $this->template->$template($data);
    }
    else
    {
        $data['upload_data'] = $this->upload->data();
        $template = "bootstrap_theme";
        $data['view_file'] = "upload_success";
        $this->load->module('template');
        $this->template->$template($data);
    }
}

这是上传表单视图:

<?php echo $error;?>
<?php echo form_open_multipart('store_data/do_upload');?>
<input type="file" name="userfile" size="20" />
<br /><br />
<input type="submit" value="upload" />
</form>

我解决了这个问题。我不得不在php.ini和注释中取消注释extension=php_fileinfo.dll;extension=php_mime_magic.dll

无论如何都要感谢

最新更新