[eluser]dibs[/eluser]
Hey.
I'm no expert coder but I though I might submit this in-case it helps others.
The upload class was failing for me when I had specified only .png, .gif and .jpg as allowed types but then tried a .css file in test. Unfortunately it made it to the getimagesize() call wich made my page crash so I added this to MY_Upload to prevent it.
Let me know if it's of any help.
Sorry if this is not the correct place to leave code for codeIgniter I am in a hurry, it's Friday! TGIF!
::FROM upload library ::
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));
/**
* Return FALSE is file is not of correct type before we try getimagesize() as this will cause trouble.
*/
//remove . from this->file_ext
$x = substr($this->file_ext,1);
if (!in_array($x, $this->allowed_types)) {
//echo "wtf morrisey?";
return FALSE;
}
// Images get some additional checks
if (in_array($val, $image_types))
{
if (getimagesize($this->file_temp) === FALSE)
{
return FALSE;
}
}
if (is_array($mime))
{
if (in_array($this->file_type, $mime, TRUE))
{
return TRUE;
}
}
else
{
if ($mime == $this->file_type)
{
return TRUE;
}
}
}
return FALSE;
}
p.s. the morrisey comment is essential I think.