Quantcast
Channel: ASPRunner forums
Viewing all articles
Browse latest Browse all 2586

Saving Signature Image into database as blob

$
0
0
Hi,

Referring to this thread: https://asprunner.com/forums/topic/26463-signaturepad-edit-to-store-in-database-blob/page__hl__signature%20pad__fromsearch__1

Background:

I need to do the same, reason being i have 2 same websites on 2 different servers (one is primary and the other secondary site, in case primary is not accessible) ,
they point to the same database, so storing signature images in a folder will not be ideal and i want to minimize the risk of losing the physical signature image files
when updating codes on both sites.

So i need to save the signature images into database so that both sites can access at the same time.

What i did:

I edited the sources and checked output file at:

source at Documents\PHPRunnerPlugins\edit\SignaturePad\EditSignaturePad.php
output \project_folder\signature-to-image.php


EditSignaturePad.php file modification:

		
...
// original codes 
$water_img = imagecreatefrompng($filename);
$water_size = getimagesize($water_img);
imagecopy($img, $water_img, 0, 0, 0, 0, $this->width, $this->height);
imagepng($img, $filename);
...

 // my codes inserted after line 160 to store image into database blob field: "signature"
ob_start();
imagepng($img);
$imagevariable = ob_get_contents();
ob_end_clean();
$output = $imagevariable;

// Create some other pieces of information about the user
//  to confirm the legitimacy of their signature
$created = time();
$ip = $_SERVER['REMOTE_ADDR'];
$data = array();
$data["signature"] = $imagevariable;
$data["date_created"] = $created;
DB::Insert("signatures_test", $data );



The above was inserted successfully with data saved to the "date_created" field,
but the image was not stored in to the field "signature" in the table above, it is empty.

What did i do wrong?

Thanks for helping.

ACP

Viewing all articles
Browse latest Browse all 2586

Trending Articles