【发布时间】:2014-10-05 19:13:36
【问题描述】:
我正在尝试使用 codeigniter 上传文件,无论我尝试了什么,我都会收到错误消息,即我实际上没有选择文件。
我的控制器看起来像这样
public function editHeader()
{
$this->require_auth();
$config['upload_path'] = './files/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '1000KB';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload('userfile'))
{
$error = array('error' => $this->upload->display_errors());
var_dump($error);
}
else
{
$data = array('upload_data' => $this->upload->data());
echo('yeah!');
}
}
而我的 html 只是一个 codeigniter 表单
<?foreach($header as $row) :?>
<?=form_open_multipart('admin/editHeader');?>
<input class="waitForLoad fadeInDown" type="file" name="userfile" />
<input type="submit" name="submit" value="Change" class="btn btn-success pull-right" />
</form>
<?endforeach;?>
我已经尝试了正常的解决方案,例如增加max_size 以及将上传名称放在 do_upload 函数中,但似乎没有任何效果,我正要拔掉头发。任何帮助表示赞赏!
【问题讨论】:
标签: php codeigniter