M
M
mrRoss2015-10-22 21:38:09
PHP
mrRoss, 2015-10-22 21:38:09

How to display a picture, having its binary code?

Hello!
Using php, you need to display an image in the browser, the binary code of which is in the MSSQL table (field type image).
Binary code: "0xFFD8FFE000104A46494...."
jpg picture. Has anyone experienced this, please help.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Ernest Faizullin, 2015-10-22
@mrRoss

header('Content-Type: image/jpeg;');

$data = 'бинарный код...';

$data = pack('H*',$data);

$im = imagecreatefromstring($data);

imagejpeg($im);

A
Aleksey Ratnikov, 2015-10-22
@mahoho

I kind of advised wrapping in base64:

<img src="data:image/jpeg;base64,<?php echo base64_encode($image); ?>" />

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question