function toBase64()
{
- if(!preg_match($pattern, $subject)){
+ if(!preg_match('/^image\//', $this->mimetype)){
return false;
}
return false;
}
- $type = pathinfo($file, PATHINFO_EXTENSION);
- $data = file_get_contents($path);
- $base64 = 'data:image/' . $type . ';base64,' . base64_encode($data);
+ $data = file_get_contents($file);
+
+ $base64 = 'data:' . $this->mimetype . ';base64,' . base64_encode($data);
+
+ return $base64;
}
}