Example #1
0
 /**
  * Before the model is saved
  * - check if new file data has been supplied, eg: $model->data = 'http://domain.tld/image.jpg';
  */
 public function beforeSave()
 {
     if (filter_var($this->data, FILTER_VALIDATE_URL) !== false) {
         $this->fromUrl($this->data);
     }
     parent::beforeSave();
     // Delete downloaded file from temp
     if ($this->tempFile) {
         @unlink(realpath($this->tempFile));
     }
 }