I need to upload file using CI (version 3.0)
this is my view
file
image_gallery.php
<?php
echo form_open_multipart('gallery_control');
echo form_upload('userfile', 'upload_image');
echo form_submit('submit', 'Upload');
echo form_close();
?>
this my controllers
file
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);
}
}
this my models
file
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();
}
}
this is my coding path after run this. I'm not getting image in uploaded_images
folder which I created out site the application
folder and there is no error showing it is returning to index page (image_gallery.php
). whats wrong with my coding please help me?