|
本帖最后由 skeay 于 2011-2-28 16:03 编辑
管理员你好:
我在练习CI上传的时候:
member.php 是一个控制器,www是CI index.php和system所在目录
代码如下,先谢谢大大们。
member.php
PHP复制代码
function photo ()
{
$config['title'] ="Post Photo";
$config['url'] = base_url ();
$this->load->helper(array('form', 'url'));
$this->load->view('header',$config);
$this->load->view('action/photo',array('error' => ' ' )); //Change
$this->load->view('admin_left');
$this->load->view('includes/footer',$config);
}
function photo_up ()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png';
$config['max_size'] = '100';
$config['max_width'] = '1024';
$config['max_height'] = '768';
$this->load->library('upload', $config);
if ( ! $this->upload->photo_up()) //这行出错了,和手册上一样的结构写就没有错误
//手册上是有个控制器叫Upload,而我的控制器叫Member,把$this->upload->photo_up() 的upload改member也不对;也不知道这个upload是不是系统自带的,如果是的话不应该出错啊
//用$this->photo_up();也不行会提示
[attach ]1220[/attach ][attach ]1223[/attach ]
//而加上了还是显示
[b ]//Fatal error: Call to undefined method CI_Upload::photo_up() in /opt/lampp/htdocs/www/application /controllers/member.php
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('action/photo', $error);
}
else
{
$data = array('upload_data' => $this->upload->data());
$this->load->view('upload_success', $data);
}
}
复制代码 |
|