This is similar to the file upload recipe mentioned earlier in the book; however, it differs from it, as we're making CodeIgniter upload images (rather than upload any file type) and perform specific tasks on images, which wouldn't be relevant to the other upload example in the book. Hence, consider this as a separate upload script. This script is the base script for the other recipes (apart from the CAPTCHA recipe) in this chapter—that is to say that the rotating, watermarking, resizing recipes and so on require this base recipe to function.
We're going to create the following two files:
/path/to/codeigniter/application/controllers/upload.php
/path/to/codeigniter/application/views/upload/upload.php
Create the controller file,
upload.php
, and add the following code to it:<?php if (! defined('BASEPATH')) exit('No direct script access allowed'); class Upload extends CI_Controller { function __construct() { parent::__construct(); ...