Skip to content

Instantly share code, notes, and snippets.

@vrkansagara
Created September 8, 2015 16:01
Show Gist options
  • Save vrkansagara/0ace211b43698bc2df4a to your computer and use it in GitHub Desktop.
Save vrkansagara/0ace211b43698bc2df4a to your computer and use it in GitHub Desktop.
upload image file.
<?php
/**
* Created by PhpStorm.
* User: vallabh
* Date: 08/09/15
* Time: 17:34
*/
class Test 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()
{
$this->load->library('upload');
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);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment