CodeIgniter Plupload problems – a solution!

TL;DR

Fix the codeigniter plupload upload problem of  “You did not select a file to upload.”  by making sure that you pass the correct file array key to do upload:

$this->upload->do_upload('file');

==============================

How I found it:

I’ve been working on my first codeigniter project that required me to upload some images. For that task I chose Plupload. A super slick upload manager written by the same people that brought us tinymce.

The problem, after setting up the upload controller, and verifying that it worked, I pointed plupload to my controller and consistently was getting errors.

You did not select a file to upload.

I started googling around for some answers, only to find this thread on the plupload support forums.

http://www.plupload.com/punbb/viewtopic.php?id=28

I made the suggested changes, though they didn’t seem to truly address my problem, but still had no joy.

So I decided to actually pop open the uploads library for codeigniter, and I found that

$this->upload->do_upload();

Defaults to look for “userfile”

And the name of the $_FILES array key that plupload is passing is “file”;

So dropping the correct name into my do_upload function fixed it.

Fix the codeigniter plupload upload problem of  “You did not select a file to upload.”  by making sure that you pass the correct file array key to do upload:

$this->upload->do_upload('file');