More work and troubleshooting image upload

This commit is contained in:
sctn4elk 2024-05-14 20:11:04 -05:00
parent cf1fb1bc63
commit 0a78c4fddc
10 changed files with 22 additions and 20 deletions

View File

@ -1,12 +1,11 @@
<?php <?php
header("Content-Type: application/json"); header("Content-Type: application/json");
define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI');
require_once PD . "/Model/CustomerModel.php"; require_once PD . "/Model/CustomerModel.php";
/** /**
* Description of CustomerController * Description of CustomerController
* *
* @author SCTN4 * @author Mike Howard
* http://localhost:8000/index.php/customer/process/insert?name=Mike%20Howard&email=sctn4elk@msn.com&phone=208-841-4159&birthday=05/07/1965&loyalty=1&city=Winnsboro&state=TX&zip=75494 * http://localhost:8000/index.php/customer/process/insert?name=Mike%20Howard&email=sctn4elk@msn.com&phone=208-841-4159&birthday=05/07/1965&loyalty=1&city=Winnsboro&state=TX&zip=75494
* http://localhost:8000/index.php/customer/process/select?limit=20 * http://localhost:8000/index.php/customer/process/select?limit=20
*/ */

View File

@ -2,14 +2,13 @@
header("Content-Type: application/json"); header("Content-Type: application/json");
header("Access-Control-Allow-Origin: *"); header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST"); header("Access-Control-Allow-Methods: POST");
define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI');
require_once PD . "/Model/ImageModel.php"; require_once PD . "/Model/ImageModel.php";
/** /**
* Description of ImageController * Description of ImageController
* *
* @author SCTN4 * @author Mike Howard
*/ */
class ImageController extends BaseController { class ImageController extends BaseController {
@ -72,12 +71,13 @@ class ImageController extends BaseController {
} }
/* Upload the image and store on server as file */ /* Upload the image and store on server as file */
private function uploadImage(){ private function uploadImage() {
if ($this->checkRequestType('POST') == 'false') { if ($this->checkRequestType('GET') == 'false') {
return $this->unprocessableRequestResponse(); return $this->unprocessableRequestResponse();
} }
return var_dump(file_get_contents('php://input'));
$this->imagePayload = file_get_contents($_FILES['image']['tmp_name']); $this->imagePayload = file_get_contents($_FILES['image']['tmp_name']);
$this->imageModel->fileName = $_FILES['image']['name']; $this->imageModel->fileName = $_FILES['image']['name'];
if(empty($this->imageModel->fileName)){ if(empty($this->imageModel->fileName)){
return $this->notFoundResponse(); return $this->notFoundResponse();

View File

@ -8,7 +8,7 @@ header("Content-Type: application/json");
/** /**
* Description of PurchaseController * Description of PurchaseController
* *
* @author SCTN4 * @author Mike Howard
*/ */
class PurchaseController extends BaseController{ class PurchaseController extends BaseController{
/** /**

View File

@ -6,12 +6,12 @@
*/ */
define("PROJECT_ROOT_PATH", __DIR__ . "/../"); define("PROJECT_ROOT_PATH", __DIR__ . "/../");
//define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI');
define('PD', 'C:\DEV\UniServerZ\www\CustomerRewardsRESTAPI');
// include main configuration file // include main configuration file
require_once PROJECT_ROOT_PATH . "/include/config.php"; require_once PROJECT_ROOT_PATH . "/include/config.php";
// include the base controller file // include the base controller file
require_once PROJECT_ROOT_PATH . "/Controller/Api/BaseController.php"; require_once PROJECT_ROOT_PATH . "/Controller/Api/BaseController.php";
// include the use model file
//require_once PROJECT_ROOT_PATH . "/Model/CustomerModel.php";
//require_once PROJECT_ROOT_PATH . "/Model/ImageModel.php";
// include the tests autoloader when in development // include the tests autoloader when in development
//require_once __DIR__ . '/../vendor/autoload.php'; //require_once __DIR__ . '/../vendor/autoload.php';

View File

@ -11,25 +11,27 @@
* customer_email varchar(255) * customer_email varchar(255)
* customer_phone varchar(12) * customer_phone varchar(12)
* customer_birthday datetime * customer_birthday datetime
* customer_street varchar(255) * customer_street varchar(255)
* address_code_id bigint * address_code_id bigint
* loyalty_member tinyint * loyalty_member tinyint
* *
* address_code * address_code
* address_code_id bigint AI PK * address_code_id bigint AI PK
* address_city varchar(45) * address_city varchar(45)
* address_state varchar(45) * address_state varchar(45)
* address_zip varchar(10) * address_zip varchar(10)
*/ */
define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI');
//require_once PROJECT_ROOT_PATH . "/Model/Database.php";
require_once PD . "/Model/Database.php"; require_once PD . "/Model/Database.php";
require_once PD . "/Model/ModelTraits.php"; require_once PD . "/Model/ModelTraits.php";
class CustomerModel extends Database { class CustomerModel extends Database {
use ModelTraits; use ModelTraits;
function __construct() {
parent::__construct();
}
public function findAllCustomers() public function findAllCustomers()
{ {
return $this->processQuery("SELECT * FROM customer_view ORDER BY customer_id ASC LIMIT ?", ["i", $this->limit]); return $this->processQuery("SELECT * FROM customer_view ORDER BY customer_id ASC LIMIT ?", ["i", $this->limit]);

View File

@ -2,7 +2,7 @@
/** /**
* Description of Database * Description of Database
* *
* @author SCTN4 * @author Mike Howard
*/ */
class Database { class Database {
protected $connection = null; protected $connection = null;

View File

@ -14,7 +14,6 @@
* loyalty_value_blob blob * loyalty_value_blob blob
*/ */
define('PD', 'D:\DEV\Git Repository\CustomerRewardsRESTAPI');
require_once PD . "/Model/Database.php"; require_once PD . "/Model/Database.php";
require_once PD . "/Model/ModelTraits.php"; require_once PD . "/Model/ModelTraits.php";
@ -30,6 +29,7 @@ class ImageModel extends Database {
public $fileType; public $fileType;
function __construct() { function __construct() {
parent::__construct();
$this->uploadTo = "public/images/"; $this->uploadTo = "public/images/";
$this->allowFileType = array('jpg','png','jpeg','gif'); $this->allowFileType = array('jpg','png','jpeg','gif');
} }

View File

@ -3,7 +3,7 @@
/** /**
* Description of ModelTraits * Description of ModelTraits
* *
* @author SCTN4 * @author Mike Howard
*/ */
trait ModelTraits { trait ModelTraits {
private $params = array(); private $params = array();

View File

@ -8,7 +8,7 @@
/** /**
* Description of PurchaseModel * Description of PurchaseModel
* *
* @author SCTN4 * @author Mike Howard
*/ */
require_once PROJECT_ROOT_PATH . "/Model/Database.php"; require_once PROJECT_ROOT_PATH . "/Model/Database.php";

View File

@ -1,3 +1,4 @@
auxiliary.org-netbeans-modules-php-smarty.smarty-framework=true
browser.reload.on.save=true browser.reload.on.save=true
code.analysis.excludes= code.analysis.excludes=
ignore.path= ignore.path=