Skip to content

Instantly share code, notes, and snippets.

@vamsiikrishna
Created March 1, 2011 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vamsiikrishna/849112 to your computer and use it in GitHub Desktop.
Save vamsiikrishna/849112 to your computer and use it in GitHub Desktop.
codeigniter jQuery-File-Upload Controller
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Upload extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->helper(array('form', 'url'));
$this->load->database();
}
function index()
{
$this->load->view('form', array('error' => ' ' ));
}
function do_upload()
{
$config['upload_path'] = './uploads/';
$config['allowed_types'] = 'gif|jpg|png|jpeg';
$config['max_size'] = '36000';
$config['max_width'] = '10240';
$config['max_height'] = '76800';
$this->load->library('upload', $config);
if ( ! $this->upload->do_upload())
{
$error = array('error' => $this->upload->display_errors());
$this->load->view('form', $error);
}
else
{
$uploaded = $this->upload->data();
$this->load->view('success', $data);
}
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment