[eluser]alvk4r[/eluser]
If you try upload a file through an upload config with various mime types and include an image ext. i.e (png|pdf), then you could upload the image, but the other file report an error.
I make some changes into the core library Upload (/system/libraries/Upload.php).
The change don't affect the functionality of the class, I only change the location of one validation statement.
You can view a diff for details.
I attach the file modified.
There is the full code of method modified, make it simple copy & paste replacing the method:
Code:
/**
* Verify that the filetype is allowed
*
* @access public
* @return bool
*/
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 )) {
if (in_array ( $this->file_type, $mime, TRUE )) {
// Images get some additional checks
if (in_array ( $val, $image_types )) {
if (getimagesize ( $this->file_temp ) === FALSE) {
return FALSE;
}
}
return TRUE;
}
} else {
if ($mime == $this->file_type) {
return TRUE;
}
}
}
return FALSE;
}