[Codeigniter File Upload Class] The filetype you are attempting to upload is not allowed

Posted on Februari 23, 2012

1


OH F KIDDIN’ ME!!! After one looo…ooong day, el finale, et voila…. Ich habe est gefunden!

You got the same problem with me? The solution are here (from this guy‘s stack overflow):

****

If you’re using Codeigniter version 2.1.0 there is a BUG in the Upload library. See http://codeigniter.com/forums/viewthread/204725/  for more details.

Basically what I did was modify a few lines of code in the File Upload Class (Location: ./system/libraries/Upload.php)

1) modify Line number 1044

from:

$this->file_type = @mime_content_type($file['tmp_name']);
return;

to this:

$this->file_type = @mime_content_type($file['tmp_name']);
if (strlen($this->file_type) > 0) return;

2) modify line number 1058

from:

@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_path']), $output, $return_code);

to this:

@exec('file --brief --mime-type ' . escapeshellarg($file['tmp_name']), $output, $return_code);

As you can probably see, line 1058 tries to use an array value that does not exist.