return false;
}
+ if (!empty($this->imgtype) && $this->imgtype[0] == '-' && !empty($this->onid)) {
+ // then its an upload
+ $img = DB_DataObject::factory('Images');
+ $img->onid = $this->onid;
+ $img->ontable = $this->ontable;
+ $img->imgtype = $this->imgtype;
+
+ $img->find();
+ while ($img->fetch()) {
+ $img->beforeDelete();
+ $img->delete();
+ }
+
+ }
+
require_once 'File/MimeType.php';
$y = new File_MimeType();
$ext = $y->toExt(trim((string) $this->mimetype ));
- $this->filename = $this->filename .'.'. $ext;
+ if(array_pop(explode('.', $this->filename)) != $ext){
+ $this->filename = $this->filename .'.'. $ext;
+ }
if (!$this->createFromData($data)) {
return false;