Take the 2-minute tour ×

I am trying to extend the Upload library in CodeIgniter. I have been trying all morning, following various tuts and forum posts, but can't get it to work.

If I add the function I want directly into the Upload.php library, it works-- but I know this isn't the right way, and want to do it right since I'm doing it.

Here is the content of the extension [system/application/libraries/MY_Upload.php]:


class MY_Upload extends Upload{
function MY_Upload(){
  function mupload($configs,$files){
    if(count($configs) != count($files)){
       return 'array_count_wrong';
    for($i=0, $j = count($files);$i<$j;$i++){


And relevant controller code:


It fails with no indication of why.

What am I doing wrong?


share|improve this question

2 Answers 2

up vote 2 down vote accepted

Missing a friggin } at the end of the extension


I REALLY REALLY REALLY wish there was a way to get more informative error messages (or any message at all) when things fail...

share|improve this answer
You could enable PHP error reporting (php.net/manual/en/…) while in a development environment; also, using a good editor or IDE with proper syntax highlighting will help you catch syntax errors like the one you described. –  gpmcadam Mar 4 '10 at 23:13
error reporting is most definitely on. Set to 11, even. I use TextMate (which I lub), but it doesn't seem to highlight blocks, just functions, vars, arrays, etc. It'll blink if you try and put a closing bracket with no matching opening bracket, but doesn't really help when dealing with 10k lines of code. Thanks. –  stormdrain Mar 9 '10 at 16:58
You might lub another editor, like vim, even better. vim's static analysis is more powerful: stackoverflow.com/questions/378959/…. –  g33kz0r Dec 17 '10 at 21:55

A few extra bits of advice here.

  1. You should extend from CI_Upload not Upload
  2. You only need to add a contructor with parent::CI_Upload; if you are actually doing something in your controller. Delete function MY_Upload() as you don't need it. :-)

Glad you solved your main problem though!

share|improve this answer
Indeedidly. I had the CI_ in there most of the time, but not when I copied the code to paste here. It's in there now :) I also deleted the MY_Upload function. Though I'm not clear why... You said "if you're actually doing something in your controller". I think I'm doing stuff in my controller, aren't I? Do you mean calling functions in the parent class directly inside the controller? Thx. –  stormdrain Mar 9 '10 at 17:02
Sorry replace the word controller with constructor. Basically if you create your own constructor then you need to cal the parents constructor first as when you make a function in the child of an inherited class you are essentially replacing it. If you are not using a constructor in your MY_ class, then you do not need to put an empty constructor in. :-) –  Phil Sturgeon Mar 10 '10 at 9:58

Your Answer


