Welcome Guest, Not a member yet? Register   Sign In
File Upload Class - MIME type detection error - 2.1.0
#4

[eluser]StickGrinder[/eluser]
Just in case someone else has this error and above solutions don't work:

I'm running CI 2.1 (vanilla) on PHP 5.3.10 - (mod_php, Ubuntu server) and the error persists.
Figured out that in system/libraries/Upload.php, from line 597 the following code

Code:
$ext = strtolower(ltrim($this->file_ext, '.'));

        if ( ! in_array($ext, $this->allowed_types))
        {
            return FALSE;
        }

invariabily fails, since for what I think is a bug in PHP, $ext value before the if statement is correct, while after the if statement (and during it, it seems), it changes.

To check this out try this:

Code:
$ext = strtolower(ltrim($this->file_ext, '.'));

        echo var_dump($ext);

        if ( ! in_array($ext, $this->allowed_types))
        {
            die(var_dump($ext));
            return FALSE;
        }

Changing the variable name to $fext across all class did the trick for me: the value remains untouched.

EDIT: I lied! It fails equally. The ONLY viable solution I found is to use a constant instead. AWFUL solution follows!


Code:
define('ULFEXT', strtolower(ltrim($this->file_ext, '.')));

        if ( ! in_array(ULFEXT, $this->allowed_types))
        {
            return FALSE;
        }

        $ext = ULFEXT;

Thanks PHP. And if someone is thinking about testing out some other framework, my advice is to frog-leap to another language too. Tongue meh.


Messages In This Thread
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 11-17-2011, 01:35 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 04-16-2012, 09:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 04-19-2012, 12:08 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 05-16-2012, 08:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 05-17-2012, 10:35 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 06-27-2012, 10:59 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-06-2012, 02:39 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-17-2012, 11:52 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-22-2012, 10:21 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-22-2012, 11:53 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-23-2012, 01:42 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 08-27-2012, 04:34 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-11-2012, 12:12 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-12-2012, 01:00 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 09-20-2012, 02:30 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 07-17-2013, 11:46 AM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 11-20-2013, 09:29 PM
File Upload Class - MIME type detection error - 2.1.0 - by El Forum - 08-26-2014, 08:10 AM



Theme © iAndrew 2016 - Forum software by © MyBB