S
S
serNevajno2017-10-16 20:14:25
1C-Bitrix
serNevajno, 2017-10-16 20:14:25

How to extract an image from MS SQL database?

Hello uv. community. Tell me, please, I am deriving a field with the image type from the MS SQL database, where the image is stored in binary format (0хFFD8FFE000104A46494600010100000100010000F...). When requested, only a part of the picture (4 kb) is displayed. What could be the problem?
Here is the code:

$con = mssql_connect($server, $user, $pass) or die("Couldn't connect to MSSQL Server on $server");

$result = mssql_query("SELECT TOP (1) Data FROM nameTable WHERE id='2310'");
$item = mssql_fetch_assoc($result);
echo '<img alt="" src="data:image/jpg;base64,'.base64_encode($item['Data']).'">';

Answer the question

In order to leave comments, you need to log in

5 answer(s)
A
Alexey Emelyanov, 2019-07-15
@babarun

See https://dev.1c-bitrix.ru/api_help/main/general/url...
But it's better not to do this, I advise you to do one nesting level, for example: /brands/panasonic/

S
Stalker_RED, 2019-07-15
@Stalker_RED

Can.

H
hesy, 2019-07-15
@hesy

no extra folders

if folders - then create a folder / panasonic in the root?
if not, then use routing

S
serNevajno, 2017-10-17
@serNevajno

I solved the problem, the whole thing was in mssql.textlimit = 4096.

D
d-stream, 2017-10-16
@d-stream

Most likely in the interpretation of the varbinary field as varchar
https://codedump.io/share/OoDafDX5wXC2/1/cannot-fe...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question