mirror of
https://github.com/sctn4elk/CustomerRewardsRESTAPI.git
synced 2025-01-10 08:54:30 -06:00
74 lines
2.3 KiB
PHP
74 lines
2.3 KiB
PHP
<?php
|
|
require_once PD . "/Model/Database.php";
|
|
require_once PD . "/Model/ModelTraits.php";
|
|
|
|
/**
|
|
* Description of ImageModel
|
|
*
|
|
* @author Mike Howard
|
|
*
|
|
* Table: loyalty_value_blob
|
|
* Columns:
|
|
* loyalty_value_id bigint PK
|
|
* loyalty_member_id bigint
|
|
* loyalty_attribute_id bigint
|
|
* loyalty_value_mime_type varchar(255)
|
|
* loyalty_value_blob blob
|
|
*/
|
|
|
|
class ImageModel extends Database {
|
|
use ModelTraits;
|
|
|
|
public $memberId;
|
|
public $imagePath;
|
|
public $imageName;
|
|
public $imageType;
|
|
public $imageSize;
|
|
public $imageBlob;
|
|
|
|
public $uploadTo;
|
|
public $allowFileType;
|
|
public $fileName;
|
|
public $tempPath;
|
|
public $basename;
|
|
public $originalPath;
|
|
public $fileType;
|
|
|
|
function __construct() {
|
|
$this->uploadTo = PD . "\\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()
|
|
{
|
|
//$escaped_string = mysql_real_escape_string($this->imageBlob);
|
|
//$escaped_string = addslashes($this->imageBlob);
|
|
//return var_dump($escaped_string);
|
|
//$sql = "INSERT INTO ImageStore(ImageId,Image) VALUES('$this->image_id','" . mysql_escape_string(file_get_contents($tmp_image)) . "')";
|
|
|
|
//$fp=addslashes(file_get_contents($_FILES['image']['tmp_name'])); //will store the image to fp
|
|
//$query = "CALL insert_loyalty_member_image_proc('{$fileName}','{$fp}');";
|
|
|
|
/*
|
|
* $data = mysql_real_escape_string(fread(fopen($form_data, "r"), filesize($form_data)));
|
|
|
|
$result = mysql_query("INSERT INTO binary_data (description, bin_data, filename, filesize, filetype) ".
|
|
"VALUES ('$form_description', '$data', '$form_data_name', '$form_data_size', '$form_data_type')");
|
|
|
|
$id= mysql_insert_id();
|
|
*
|
|
* UPDATE t
|
|
SET blob_col=LOAD_FILE('/tmp/picture')
|
|
WHERE id=1;
|
|
*/
|
|
//$query = "CALL insert_loyalty_member_image_proc (" . $this->memberId . ", '" . $escaped_string . "');";
|
|
$query = "CALL insert_loyalty_member_image_proc";
|
|
//return var_dump($query);
|
|
|
|
$rowCount = $this->processImage($query, $this);
|
|
return $rowCount;
|
|
}
|
|
}
|