[eluser]Xiphar[/eluser]
Hi
I want to extend the Upload library.
I created a file Upload.php and put the file in the application/libraries folder.
This is how my class file look likes:
Code:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class MY_Upload extends CI_Upload {
function __construct($props = array()) {
parent::CI_Upload($props);
}
//overwrite parent function to check if a file is actually ann image
//and not simply a renamed exe/script
function is_allowed_filetype()
{
if (count($this->allowed_types) == 0)
{
$this->set_error('upload_no_file_types');
return FALSE;
}
//--- ADDED BY ME
if($this->is_image())
{
$D = @getimagesize($this->file_temp);
if($D['0'] === '')
{
return FALSE;
}
}
//--- END OF ADDITION
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;
}
}
?>
The problem is that when I am calling the upload library, I am getting the following error:
Fatal error: Class 'CI_Upload' not found in path\to\system\application\libraries\Upload.php on line 2
Any idea why? My config file has the subclass prefix set to 'MY_'.
Your help would be greatly appreciated. Right now I am getting around by making changes to the original library which I do not like.
Thanks
Xiphar