【问题标题】:Codeigniter Modular HMVC extension - cant upload fileCodeigniter 模块化 HMVC 扩展 - 无法上传文件
【发布时间】:2014-12-23 03:07:08
【问题描述】:

我在按表单上传文件时遇到问题。每次尝试时,我都会收到错误“文件类型不允许”。我正在使用 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>

【问题讨论】:

    标签: codeigniter file-upload hmvc


    【解决方案1】:

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

    还是谢谢

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2013-08-31
      • 2015-09-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-09-27
      相关资源
      最近更新 更多