[eluser]Colin Williams[/eluser]
This is a dead-easy implementation.
application/libraries/MY_Upload.php
Code:
class MY_Upload {
// --------------------------------------------------------------------
/**
* Verify that the filetype is allowed
*
* @access public
* @return bool
*/
function is_allowed_filetype()
{
if (count($this->allowed_types) == 0 || ! is_array($this->allowed_types))
{
// Return TRUE instead of failing. I would recommend a more concrete way of allowing all file types
return TRUE;
}
foreach ($this->allowed_types as $val)
{
$mime = $this->mimes_types(strtolower($val));
if (is_array($mime))
{
if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
}
}
else
{
if ($mime == $this->file_type)
{
return TRUE;
}
}
}
return FALSE;
}
}