Codeigniter模块化HMVC扩展 - 无法上载文件
问题描述:
我有一个按窗体上传文件的问题。每次尝试时,都会收到错误“文件类型不允许”。我使用HMVC模块化扩展,我的控制器扩展了MX_Controller。Codeigniter模块化HMVC扩展 - 无法上载文件
我已经试过$ 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_fileinfo.dll在php.ini和评论;延长= php_mime_magic.dll
还是要谢谢你