on 08-14-2012 1:48 PM
Hi all,
I need to get a binary image in a DB ( SQL Server using SQlQuery) and Display it in a HTML. Anybody Know how to do it?
Regards,
Marcelo,
You can use the data: URI scheme to embed a base64 right into the src attribute of an image tag .
<img id="myImage" src="data:image/png;base64,/9j/4AAQSkZJRgABAQEAYAB…….”>
In your case, use a query template to return the varbinary as varchar
Example: SELECT CAST(image_text as varchar(max)) AS image_text FROM ImageTable
base64Decode the binary string at the client side by using JavaScript and dynamically modify the “src” attribute of the <img> tag.
Use the below to dynamically modify the src attribute (Refer to the attachment for the JavaScript function - Convert).
document.getElementById("myImage").src=="data:image/png;”+Convert(<<applet>>.getFirstValue(' image_text '));
Thanks,
Johnson
PS: I couldn't get this into work by using a base64decode function in BLS or by using a custom SQL function so I did the the conversion at the client side.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
11 | |
6 | |
2 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 | |
1 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.