Created
March 1, 2011 13:21
-
-
Save vamsiikrishna/849112 to your computer and use it in GitHub Desktop.
codeigniter jQuery-File-Upload Controller
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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