[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;
}
}