N
N
NataliaCh2019-09-11 13:24:33
PHP
NataliaCh, 2019-09-11 13:24:33

How to extract files from binary data to MSSQL DB?

There is a table in the sql server database (2008), which stores files (of various formats, mainly doc and pdf) in a field with a varbinary data type. You need to go through the table and pull out all the files in the folder as the actual files.
To begin with, I experiment with one doc file - I pull out binary data into a variable and try to open the file in the browser.

$file_body ='0xA8A930310C00000052020000789C6D50CD4E834010B....';
header('Content-type: application/doc');
header('Content-Disposition: attachment; filename="doc.doc"');
echo $file_body;

But in the end, in the dock file, I get a line with binary data.
Obviously this is wrong. And how is it necessary?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Adamos, 2019-09-11
@NataliaCh

$file_body = gzinflate('0xA8A930310C00000052020000789C6D50CD4E834010B....');
// или 
$file_body = zlib_decode('0xA8A930310C00000052020000789C6D50CD4E834010B....');

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question