在codeigniter中我的文件上传编码有什么问题

时间:2015-11-25 03:23:12

标签: php html codeigniter-3

我需要使用 CI (版本3.0)上传文件 这是我的 view 文件
image_gallery.php

<?php 
  echo form_open_multipart('gallery_control');
  echo form_upload('userfile', 'upload_image');
  echo form_submit('submit', 'Upload');
  echo form_close();
?>  

我的 controllers 文件
gallery_control.php

class Gallery_control extends CI_Controller 
{

  function index()
  {

    $this->load->model('gallery_model');

    if($this->input->post('upload'))
    {
        $this->gallery_model->do_upload();
    }
    else
    {
        //$this->gallery_model->display_errors();
    }
    //here I used template to call view file
    $data['main_content'] = 'image_gallery';
    $this->load->view('includes/template', $data);
  }
}   

我的 models 文件
gallery_model.php

class Gallery_model extends CI_Model 
{
  var $gallery_path;

 public function __construct()
    {
        parent::__construct();

     //$this->load->helper(array('form', 'url')); #autoloaded from config file
       $this->gallery_path = realpath(APPPATH . '../uploaded_images');
    }


  public function do_upload()
  {
    $config = array(
            'allowed_types' => 'gif|png|jpeg',
            'upload_path' => $this->gallery_path,
            'max_size' => 2000
        );

    $this->load->library('upload', $config);

    $this->upload->do_upload();
  }
}  

这是我运行此后的编码路径。我没有在uploaded_images文件夹中获取我在application文件夹中创建网站的图像,并且没有错误显示它正在返回索引页面(image_gallery.php)。我的编码有什么问题请帮帮我?

0 个答案:

没有答案