# Easy Development With CodeIgniter

In this week's 30 minute screencast, I'm going to show you how easy it is to work with the MVC pattern and CodeIgniter. This video is aimed at beginners who have no experience with a PHP framework.

For demonstration purposes, we'll be building a simple image upload utility. We'll then perform some validation, save the file to our uploads folder, and automatically create a respective thumbnail. With raw PHP, this can be somewhat time-consuming. However, with CodeIgniter, it's simply a matter of referencing the correct library, and passing in some configuration options! Let's dive in.

### Final Controller

 1 load->helper('form');  8  }  9   10  function index() {  11  $this->load->view('upload_form');  12  }  13   14  function doUpload() {  15 $config['upload_path'] = 'uploads/';  16  $config['allowed_types'] = 'gif|jpg|jpeg|png';  17 $config['max_size'] = '1000';  18  $config['max_width'] = '1920';  19 $config['max_height'] = '1280';  20   21  $this->load->library('upload',$config);  22   23  if(!$this->upload->do_upload()) echo$this->upload->display_errors();  24  else {  25  $fInfo =$this->upload->data();  26  $this->_createThumbnail($fInfo['file_name']);  27   28  $data['uploadInfo'] =$fInfo;  29  $data['thumbnail_name'] =$fInfo['raw_name'] . '_thumb' . $fInfo['file_ext'];  30 $this->load->view('upload_success', $data);  31  }  32  }  33   34  function _createThumbnail($fileName) {  35  $config['image_library'] = 'gd2';  36 $config['source_image'] = 'uploads/' . $fileName;  37 $config['create_thumb'] = TRUE;  38  $config['maintain_ratio'] = TRUE;  39 $config['width'] = 75;  40  $config['height'] = 75;  41   42 $this->load->library('image_lib', $config);  43  if(!$this->image_lib->resize()) echo \$this->image_lib->display_errors();  44  }  45 } 

### Final View

 1   2   3   4   5  Upload an Image  6   7   8   9   10 
 11 

 12 13   14   15 

 16   17 
 18 19   20  

I hope you guys enjoyed this video tutorial. If you'd like to see more CodeIgniter tutorials and videos on Nettuts+, please be loud in the comments. I know I'd like to see more! I'm in the process of learning this framework myself, so links to resources, tips, etc. will be much appreciated!