From 12384fc2d6b674821b82cdb3d526fba7c326cba2 Mon Sep 17 00:00:00 2001 From: sctn4elk Date: Thu, 30 May 2024 10:42:53 -0500 Subject: [PATCH] Work on member image --- Controller/API/ImageController.php | 17 ++++++++++++++--- Model/Database.php | 5 ----- Model/ImageModel.php | 5 +++++ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/Controller/API/ImageController.php b/Controller/API/ImageController.php index 264df8d..fa3d0ca 100644 --- a/Controller/API/ImageController.php +++ b/Controller/API/ImageController.php @@ -40,13 +40,16 @@ class ImageController extends BaseController { break; case "update": - $response = $this->updateImage(); + $response = $this->updateImage(); break; case "delete": - $response = $this->deleteImage(); + $response = $this->deleteImage(); break; + case "blob": + $response = $this->blobImage(); + break; default: $response = (object) ['Result' => 'Default']; $this->strErrorDesc = 'Controller Method not supported for processAction: ' . $this->action; @@ -156,7 +159,7 @@ class ImageController extends BaseController { private function handleImage() { $moved = false; - if(move_uploaded_file($this->imageModel->tempPath, $this->imageModel->uploadTo . $this->imageModel->memberId)) { + if(move_uploaded_file($this->imageModel->tempPath, $this->imageModel->uploadTo . $this->imageModel->memberId . '.' . $this->imageModel->fileType)) { $moved = true; } return $moved; @@ -216,6 +219,14 @@ class ImageController extends BaseController { return $this->unprocessableRequestResponse("deleteImage is not implemented"); } + private function blobImage(){ + if ($this->checkRequestType('GET') == 'false') { + return $this->unprocessableRequestResponse("Request type is not GET"); + } + + return $this->unprocessableRequestResponse("updateImage is not implemented"); + } + private function validateImage(){ $validtion = false; if(in_array($this->imageModel->fileType, $this->imageModel->allowFileType)){ diff --git a/Model/Database.php b/Model/Database.php index 085a1ef..7c8e8ad 100644 --- a/Model/Database.php +++ b/Model/Database.php @@ -73,11 +73,6 @@ class Database { public function processImage($query, $imageModel) { try { - /*if($this->connection == null) - { - $this->connection = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_DATABASE_NAME); - }*/ - $data = $this->connection->real_escape_string($imageModel->imageBlob); $result = $this->connection->query($query."(".$imageModel->memberId.", '".$imageModel->imageType."', '".$data."')"); diff --git a/Model/ImageModel.php b/Model/ImageModel.php index d049d0d..83e2c47 100644 --- a/Model/ImageModel.php +++ b/Model/ImageModel.php @@ -69,4 +69,9 @@ class ImageModel extends Database { FROM toast_schema.loyalty_value_blob ORDER BY loyalty_member_id ASC LIMIT ?", ["i", $this->limit]); } + + public function returnImageBlob() + { + + } }