Saving image in zzzsys_file

Questions related to using nuBuilder Forte.

Saving image in zzzsys_file

Unread postby slobodan » Sun Jun 13, 2021 4:15 pm

I tried in php to dynamically change the image of nubuilder's image object. It goes so fine until image transformation for storing into zzz sys_file.sfi_json. I expected that base64_encode and json_encode will do the job, but without success. Have you any suggestion, how to transform image file and store it in zzzzsys_file table? In attached example for testing I used qr table instead zzzzsys_file.
Attachments
php example.png
php example.png (25.14 KiB) Viewed 324 times
slobodan
 
Posts: 21
Joined: Sat May 08, 2021 8:50 pm
nuBuilder Version: 4.5

Re: Saving image in zzzsys_file

Unread postby kev1n » Sun Jun 13, 2021 4:41 pm

I think you need json_encode(), try something like this (untested)

Code: Select all
$arr = array("file"=>base64_encode($binary),
              "name"=>basename($image_name),
              "size"=>$filesize,
              "type"=>"image/png");
             
$json = json_encode($arr);
$sqlStr = "UPDATE qr set file = '$json' WHERE  id = 1";
kev1n
nuBuilder Team
 
Posts: 2059
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Saving image in zzzsys_file

Unread postby kev1n » Thu Jun 17, 2021 1:55 pm

Hi,

Did you manage to transform and save your png?
kev1n
nuBuilder Team
 
Posts: 2059
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: Saving image in zzzsys_file

Unread postby slobodan » Mon Jun 28, 2021 8:27 pm

I tried to dynamically manipulate nubuilder image object, to show QR Code with current parameters.
For QR code generation I used qrcode.js, javascript library from GitHub Pages. It shows QR code on form, something like this:
<img style="display: block;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAGQAAABkCAYAAABw4pVUAAACwUlEQVR4nO2VQXLkMAwD5/.......+AbIkwWQX1aPAhHMlIN0fTkeJ3oDBCD1MCsFEIBEe8tA3JoOxdVYaabPdR4wQAACkM290vetvFzT06FPz93wDBCAAAQgfwXIFyOtfcgN/hb5AAAAAElFTkSuQmCC">
Then I extracted src from qrcode._oDrawing._elImage.src and converted it with nuBase64encode() function to qistr, which was crucial for success. Then maked jstr = '{"file":"' + qistr + '","name":"filename.png","size":267,"type":"image/png"}' as value for update sfi_json field in zzzzsys_file table.
slobodan
 
Posts: 21
Joined: Sat May 08, 2021 8:50 pm
nuBuilder Version: 4.5

Re: Saving image in zzzsys_file

Unread postby slobodan » Mon Jun 28, 2021 8:41 pm

Forget to mention, all that were needed, for showing QR code with current parameters in the report. Whereas nuReport use only nubuilder objects, without any outside help of php or javascript.
slobodan
 
Posts: 21
Joined: Sat May 08, 2021 8:50 pm
nuBuilder Version: 4.5


Return to General

Who is online

Users browsing this forum: gerese and 28 guests