Uploading images with CodeIgniter

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.

How to do it...

We're going to create the following two files:

  • /path/to/codeigniter/application/controllers/upload.php
  • /path/to/codeigniter/application/views/upload/upload.php ...

Get CodeIgniter 2 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.