Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Saving image in zzzsys_file
-
- Posts: 25
- Joined: Sat May 08, 2021 1:20 pm
Saving image in zzzsys_file
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.
You do not have the required permissions to view the files attached to this post.
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
Re: Saving image in zzzsys_file
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";
-
- nuBuilder Team
- Posts: 4292
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 444 times
- Contact:
-
- Posts: 25
- Joined: Sat May 08, 2021 1:20 pm
Re: Saving image in zzzsys_file
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.
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.
-
- Posts: 25
- Joined: Sat May 08, 2021 1:20 pm
Re: Saving image in zzzsys_file
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.