Forums

Store signature using a {data:} variable name

DrSmith69 22 May, 2018
Hi Guys,

So i am using the signature widget and storing the image using the below code:

<?php
$data_uri = $this->data('signature');
$encoded_image = explode(",", $data_uri)[1];
$decoded_image = base64_decode($encoded_image);
file_put_contents("signature.png", $decoded_image)
?>

What I want to do is store the signature image with a unique name based on a data variable from the field i.e. {data:name}

How can I edit the above file_put_contents("signature.png", $decoded_image) to replace signature.png with a variable name?
healyhatman 23 May, 2018
file_put_contents($this->data('field_name', '') . ".png", $decoded_image);

Have a care though - what happens if two people put the same data in the field?
DrSmith69 23 May, 2018
Thanks so so much! going to test this out now.

The field is a unique identifier via my API call so will always be unique to that user.

Thanks again! going to test now
DrSmith69 23 May, 2018
Just want to update - working like a charm! Thank you!
This topic is locked and no more replies can be posted.