Added image upload to ConstructionConsent Form
This commit is contained in:
@@ -58,7 +58,26 @@ class File extends mfBaseModel {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public function asBase64String() {
|
||||
$path = $this->getFullPath();
|
||||
if(!file_exists($path) || (!is_file($path) && !is_link($path))) {
|
||||
return TT_IMAGE_PLACEHOLDER_B64;
|
||||
}
|
||||
return base64_encode(file_get_contents($path));
|
||||
}
|
||||
|
||||
public function asDataUrl() {
|
||||
$path = $this->getFullPath();
|
||||
if(!file_exists($path) || (!is_file($path) && !is_link($path))) {
|
||||
$mime = "image/webp";
|
||||
$base64 = TT_IMAGE_PLACEHOLDER_B64;
|
||||
} else {
|
||||
$base64 = $this->asBase64String();
|
||||
$mime = $this->getMimetype();
|
||||
}
|
||||
return "data:$mime;base64,$base64";
|
||||
}
|
||||
public function getFullPath() {
|
||||
/*if(!is_numeric($this->id) || $this->id < 1) {
|
||||
throw new Exception("File not found", 4040);
|
||||
|
||||
Reference in New Issue
Block a user