diff --git a/Controller/API/CustomerController.php b/Controller/API/CustomerController.php index 2a124e5..150ac48 100644 --- a/Controller/API/CustomerController.php +++ b/Controller/API/CustomerController.php @@ -1,12 +1,11 @@ requestMethod = $this->getServerRequestMethod(); - //return var_dump($this->requestMethod); + switch($this->action) { case "select": $response = $this->selectAction(); @@ -80,7 +79,6 @@ class CustomerController extends BaseController { } $this->customerModel = new CustomerModel(); - //return var_dump($this->customerModel); $this->arrQueryStringParams = $this->getQueryStringParams(); if (isset($this->arrQueryStringParams['customer_id'])) { diff --git a/Controller/API/ImageController.php b/Controller/API/ImageController.php index 7a2b695..532b0e7 100644 --- a/Controller/API/ImageController.php +++ b/Controller/API/ImageController.php @@ -1,15 +1,15 @@ unprocessableRequestResponse(); } - $this->imagePayload = file_get_contents($_FILES['image']['tmp_name']); - $this->imageModel->fileName = $_FILES['image']['name']; + $this->imagePayload = $_FILES['image']; + + $this->imageModel->fileName = $this->imagePayload['name']; if(empty($this->imageModel->fileName)){ return $this->notFoundResponse(); } - $this->imageModel->tempPath = $_FILES["image"]["tmp_name"]; + $this->imageModel->tempPath = $this->imagePayload['tmp_name']; $this->imageModel->basename = basename($this->imageModel->fileName); $this->imageModel->originalPath = $this->imageModel->uploadTo.$this->imageModel->basename; $this->imageModel->fileType = pathinfo($this->imageModel->originalPath, PATHINFO_EXTENSION); @@ -91,7 +92,7 @@ class ImageController extends BaseController { if (! $this->validateImage()) { return $this->unprocessableEntityResponse(); } - + if (! $this->handleImage()) { return $this->notFoundResponse(); } @@ -102,7 +103,7 @@ class ImageController extends BaseController { private function handleImage() { $moved = false; - if(!move_uploaded_file($this->imageModel->tempPath, $this->imageModel->originalPath)) { + if(!move_uploaded_file($_FILES['image']['tmp_name'], $this->imageModel->uploadTo . $this->imageModel->fileName)) { $moved = true; } return $moved; diff --git a/Include/bootstrap.php b/Include/bootstrap.php index c70be54..6d45b28 100644 --- a/Include/bootstrap.php +++ b/Include/bootstrap.php @@ -6,6 +6,7 @@ */ define("PROJECT_ROOT_PATH", __DIR__ . "/../"); +define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI'); // include main configuration file require_once PROJECT_ROOT_PATH . "/include/config.php"; // include the base controller file diff --git a/Model/CustomerModel.php b/Model/CustomerModel.php index fa03b56..08030a0 100644 --- a/Model/CustomerModel.php +++ b/Model/CustomerModel.php @@ -1,4 +1,9 @@ connection->stmt_init(); $stmt = $this->connection->prepare($query); if($stmt === false) { throw New Exception("Unable to prepare the statement: " . $query); diff --git a/Model/ImageModel.php b/Model/ImageModel.php index 0035bd2..6b694fd 100644 --- a/Model/ImageModel.php +++ b/Model/ImageModel.php @@ -1,4 +1,6 @@ uploadTo = "public/images/"; + $this->uploadTo = PD . "/public/images/"; $this->allowFileType = array('jpg','png','jpeg','gif'); } /* Process the uploaded image and store in database */ public function insertImage() { - //return var_dump($jsonPayLoad); - $keys = array_keys($inputModel); - $n = count($keys); - //$sql = "INSERT INTO ImageStore(ImageId,Image) VALUES('$this->image_id','" . mysql_escape_string(file_get_contents($tmp_image)) . "')"; $query .= "CALL insert_loyalty_member_image_proc (" . $inputModel[$keys[0]] . ", "; diff --git a/Model/ModelTraits.php b/Model/ModelTraits.php index 8a48042..89f0402 100644 --- a/Model/ModelTraits.php +++ b/Model/ModelTraits.php @@ -3,7 +3,7 @@ /** * Description of ModelTraits * - * @author SCTN4 + * @author Mike Howard */ trait ModelTraits { private $params = array(); diff --git a/index.php b/index.php index 1c6af53..4903f5f 100644 --- a/index.php +++ b/index.php @@ -1,14 +1,9 @@