Display a file from a SQL Server database in PHP

0

How about.

I am working with php and SQL Server. I'm trying to extract the files saved in a field like image (it's the pdf of an invoice). The field contains a value like the following:

0x255044462D312E37200A25E2E3CFD3200A312030206F626A200A3C3C200A2F54797065202F436174616C6F67200A2F5061676573203220302052200A2F506167654D6F6465202F5573654E6F6E65200A2F566965776572507265666572656E636573203C3C200A2F46697457696E646F772074727565200A2F506167654C61796F7574202F53696E67...

You want to be able to convert that value to a PDF file by PHP .

I appreciate the help.

    
asked by Julian Cabanillas Cazares 20.11.2017 в 09:19
source

1 answer

0

It's a blob type, so changing the header will be worth it.

$gotten = @mysql_query("select * from pdf order by pid desc limit 1");
$row = @mysql_fetch_assoc($gotten);
$bytes = $row[data];
header("Content-type: application/pdf");
header('Content-disposition: attachment; filename="thing.pdf"');
print $bytes;
    
answered by 20.11.2017 в 09:34