Welcome Guest, Not a member yet? Register   Sign In
Bug in Upload Class.
#2

[eluser]therendStudio[/eluser]
Seconding the issue (seems I'm not the only one but it's been widely ignored...)

However there's a simpler and shorter way to fix that method - simply move the image checking code inside the type-matched body

Code:
class MY_Upload extends CI_Upload {
    function is_allowed_filetype() {
        if (count($this->allowed_types) == 0 OR ! is_array($this->allowed_types)) {
            $this->set_error('upload_no_file_types');
            return FALSE;
        }

        $image_types = array('gif', 'jpg', 'jpeg', 'png', 'jpe');

        foreach ($this->allowed_types as $val) {
            $mime = $this->mimes_types(strtolower($val));

            if(is_array($mime) && in_array($this->file_type, $mime, TRUE)
                || $mime == $this->file_type
            ) {
                    // Images get some additional checks
                    if (in_array($val, $image_types))
                        if (getimagesize($this->file_temp) === FALSE)
                            return FALSE;
                    return TRUE;
            }        
        }
        return FALSE;
    }
}
is the whole code for overriding the method


Messages In This Thread
Bug in Upload Class. - by El Forum - 09-28-2009, 06:07 AM
Bug in Upload Class. - by El Forum - 04-06-2010, 11:01 AM
Bug in Upload Class. - by El Forum - 04-23-2010, 03:46 AM
Bug in Upload Class. - by El Forum - 04-21-2011, 12:50 PM



Theme © iAndrew 2016 - Forum software by © MyBB