Welcome Guest, Not a member yet? Register   Sign In
Upload Library Bug :: Allowed Types
#1

[eluser]dprock[/eluser]
The Allowed Type config variable takes a pipe delimited string, which is usually fine, no doubt, but for my File manager application the list looks like this:

Code:
'allowed_types' => 'hqx|cpt|csv|bin|dms|lha|lzh|exe|class|psd|so|sea|dll|oda|pdf|ai|eps|ps|smi|smil|mif|xls|ppt|wbxml|wmlc|dcr|dir|dxr|dvi|gtar|gz|php|php4|php3|phtml|phps|js|swf|sit|tar|tgz|xhtml|xht|zip|mid|midi|mpga|mp2|mp3|aif|aiff|aifc|ram|rm|rpm|ra|rv|wav|bmp|gif|jpeg|jpg|jpe|png|tiff|tif|css|html|htm|shtml|txt|text|log|rtx|rtf|xml|xsl|mpeg|mpg|mpe|qt|mov|avi|movie|doc|docx|xlsx|word|xl|eml'

However, In the Upload Library CI_Upload::is_allowed_filetype there is an additional image check for the small array 'image_types' which checks images size:

Code:
if (getimagesize($this->file_temp) === FALSE)
                {
                    return FALSE;
                }

Bug
When the non-image temp file fails this check, the script returns FALSE, which isn't so good when you are trying to upload a non-image.

I have a workaround and a fix:

Workaround
Place the image extensions at the end of your delimited list: e.g.

Code:
'...|gif|jpeg|jpg|jpe|png';

Fix
Passes thru MY_Upload::is_image to get a boolean response on the $this->file_type, which checks File Type against the mimes array values.
Create a MY_Upload Lib extension in your 'application/libraries' folder.

For MY_Upload::is_allowed_filetype wrap the above conditional with this:
Code:
if ($this->is_image())
                {
                    if (getimagesize($this->file_temp) === FALSE)
                    {
                        return FALSE;
                    }
                }


Messages In This Thread
Upload Library Bug :: Allowed Types - by El Forum - 02-14-2009, 04:04 PM
Upload Library Bug :: Allowed Types - by El Forum - 02-15-2009, 04:11 AM
Upload Library Bug :: Allowed Types - by El Forum - 02-15-2009, 05:20 AM
Upload Library Bug :: Allowed Types - by El Forum - 02-15-2009, 11:29 AM
Upload Library Bug :: Allowed Types - by El Forum - 03-11-2009, 07:34 PM



Theme © iAndrew 2016 - Forum software by © MyBB