CodeIgniters Image Library

Frameworks can make a developers life and job a lot simpler, but that doesn’t mean they don’t come with their own headaches and hours of frustration.

Tonight I’ve been coding an image uploading script using the CodeIgniter PHP Framework. This was the first time I’ve used the built-in image library to help me cut down my coding time.

Following the user guide at http://codeigniter.com/user_guide I was attempting to load an image that had been saved to the server, from the file uploading class. The example on the website uses the following example code:

This code actually doesn’t work, and will result in an error “Your server does not support the GD function required to process this type of image”.

Why doesn’t it work?

As posted on the CodeIgniter Forums by user ‘gunter’, you shouldn’t loop through

Instead what you should do is:

(courtesy of a.somervell)

A lesson to show you that not even the documentation can always be correct. Hopefully this saves some people hours of pulling their hair out.

Recommended Posts
  • Lloyd Baumgarner

    This is a well written article that I have bookmarked for future reference. Have a good one.

  • You know one would think they would update the docs, But the funny thing is now I have it creating the thumbs and still shows the error. I really thought I was enjoying Codigniter until I ran into this and file uploading. Anyway thanks for sharing much appreciated.

  • Urfi Ansari

    If nothing works (my case), the error might actually be the whole issue.

    1. Check if you have gd installed, on linux you would do

    sudo yum list installed | grep php

    2. If not installed, install it

    sudo yum install php-gd-package-name
    3. RESTART your apache

    sudo service httpd restart

Start typing and press Enter to search