关于php mvc codeigniter上传问题。 [英] regard to upload problem in php mvc codeigniter.

查看:56
本文介绍了关于php mvc codeigniter上传问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的upload_form.php,它位于application / view / upload_form.php中,代码为:

< html>

< head>

< title>上传表单< / title>

< / head>

< body>





< input type ='file'name ='userfile'size ='20'/>




<输入类型='submit'value ='Upload'/>

< / form>

< / body>

< / html> ;



这是我在upload_success.php的成功页面,在application / view / upload_success.php中,它的代码是:



< html>

< head>

< title>成功上传< / title>

< / head>

< body>

您的文件已成功上传!





    $ value):?>







< / body>

< / html> < br $>




这是控制器页面upload.php,它位于application / controller / upload.php中,代码为:



班级上传扩展CI_Controller

{

公共职能_construct()

{

parent :: construct();

$ this-> load-> helper(array('form','url'));

}



公共功能指数()

{

$ this-> load-> view(' upload_form',array('error'=>''));

}

公共函数do_upload()

{

$ config ['upload_path'] ='./uploads /';

$ config ['allowed_types'] ='gif | jpg | png';

$ con fig ['max_size'] = 100;

$ 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());



$ this-> load-> view('upload_form',$ error);

}

其他

{

$ data = array('upload_data'=> $ this-> upload-> data( ));



$ this-> load-> view('upload_success',$ data);

}

}

}

?>



并在浏览器的url上执行错误是找不到upload_form.php页面。并没有加载该页面,我不明白上传文件夹中的那种配置。如果我做的任何错误或任何方式更好的指导。谢谢你的帮助。

解决方案

value):?>







  • < / body>

    < / html>





    这是控制器页面upload.php,它位于application / controller / upload.php和代码中:



    班级上传扩展CI_Controller

    {

    公共职能_construct()

    {

    parent :: construct();


    this-> load-> helper(array('form','url'));

    }



    公共功能指数()

    {


    < blockquote> this-> load-> view('upload_form',array('error'=>''));

    }

    public function do_upload( )

    {


    this is my upload_form.php which is in application/view/upload_form.php and code:
    <html>
    <head>
    <title> upload form </title>
    </head>
    <body>


    <input type='file' name='userfile' size='20' />


    <input type='submit' value='Upload' />
    </form>
    </body>
    </html>

    this is my success page of upload_success.php which in application/view/upload_success.php and it's code:

    <html>
    <head>
    <title> success upload </title>
    </head>
    <body>

    your file was successfully uploaded!



      $value):?>
    • :



    </body>
    </html>


    and this is controller page upload.php which is in application/controller/upload.php and code:

    class upload extends CI_Controller
    {
    public function _construct()
    {
    parent::construct();
    $this->load->helper(array('form','url'));
    }

    public function index()
    {
    $this->load->view('upload_form',array('error'=>''));
    }
    public function do_upload()
    {
    $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->do_upload('userfile'))
    {
    $error = array('error' => $this->upload->display_errors());

    $this->load->view('upload_form', $error);
    }
    else
    {
    $data = array('upload_data' => $this->upload->data());

    $this->load->view('upload_success', $data);
    }
    }
    }
    ?>

    and executes on url of browser the error is that the upload_form.php page not found. and not load that page and i don't understand that what kind of configuration at upload folder .if any kind of mistakes that i did or any way for better guidence. thank u for help.

    解决方案

    value):?>
  • :



  • </body>
    </html>


    and this is controller page upload.php which is in application/controller/upload.php and code:

    class upload extends CI_Controller
    {
    public function _construct()
    {
    parent::construct();


    this->load->helper(array('form','url'));
    }

    public function index()
    {


    this->load->view('upload_form',array('error'=>''));
    }
    public function do_upload()
    {


    这篇关于关于php mvc codeigniter上传问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆