$ext = $y->toExt(trim((string) $this->mimetype ));
$this->filename = empty($this->filename) ?
- ('gen-' . date('Y-m-d H:i:s') . '.' . $ext) : ($this->filename .'.'. $ext);
+ ('image-upload-' . date('Y-m-d H:i:s') . '.' . $ext) : ($this->filename .'.'. $ext);
if (!$this->createFromData($data)) {
return false;
}
+
return true;
}
if (array_shift(explode('/', $this->mimetype)) == 'image') {
- $imgs = @getimagesize($file);
+ $imgs = @getimagesize($data);
if (!empty($imgs) && !empty($imgs[0]) && !empty($imgs[1])) {
list($this->width , $this->height) = $imgs;
}
}
-// $this->filesize = filesize($file);
$this->created = date('Y-m-d H:i:s');
if (!$this->id) {
file_put_contents($f, file_get_contents("data://" . $data));
+ $o = clone($this);
+
+ $this->filesize = filesize($f);
+
+ $this->update($o);
+
return true;
}