SQL Server Binary Data Image Display

QuestionsSQL Server Binary Data Image Display
Michael Sheppard asked 2 months ago

Are there any plans to include direct Binary Image display from an SQL Server Image (BLOB) data-type?

I understand I can use a download/file reference method, but I was wondering if direct-display of the Image Data type is planned or possible to add in the future.

Thanks

 

Mike

3 Answers
Abu Ghufran Staff answered 1 month ago

Hello,

I think this can be done using html code, where ‘uploadField’ is the database column name of grid.

$col["default"] = '<img src="data:image/jpeg;base64,'.base64_encode({uploadField}) .'" />';

Ref: https://stackoverflow.com/a/20556836/385377

_________________________
Abu Ghufran - Dev Team
Grid 4 PHP Framework
 
Michael answered 1 month ago

I did try that method, but that is for MySQL.

I should have been more specific, I’m using Microsoft SQL Server.

As soon as I bring-in a BINARY field that’s an image-type (JPG, BMP) to a report I get a pop-up “ERROR” on the grid and no data returned. I suspect the issue has to to do with the way SQL Server stores the binary image data compared to MySQL. So I don’t think the data is being returned to the report-engine to process.

The $g->debug doesn’t show anything obvious and there’s nothing obvious in the Console/Debug in Chrome.

The same binary field can contain text and as long as there is text in the field and not an image, it displays fine. The DB Schema has a TYPE so I know whether the field is text or a photo/graphic.

I have a work-around with a helper page that returns a URL with the right header settings – but it would ideally be more convenient if I could process it directly on the report.

Thanks

Mike

Abu answered 1 month ago

Mysql also uses binary data to save in database. The base64_encode function is used for the same reason.

As in https://www.php.net/manual/en/function.base64-encode.php – This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.

If it does not solve, You can share your full grid code for review.

 

Your Answer

6 + 14 =

Login with your Social Id:

OR, enter

Attach code here and paste link in question.
Attach screenshot here and paste link in question.



How useful was this discussion?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate it.

We are sorry that this post was not useful for you!

Let us improve this post!

Tell us how we can improve this post?