Added image upload to ConstructionConsent Form

This commit is contained in:
Frank Schubert
2025-01-13 19:06:50 +01:00
parent 15bfe7c734
commit f2cfefc7a2
6 changed files with 83 additions and 5 deletions

View File

@@ -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);