note 99919 deleted from function.mssql-query by danbrown

From: Date: Wed, 15 Sep 2010 15:21:30 +0000
Subject: note 99919 deleted from function.mssql-query by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-172576@lists.php.net to get a copy of this message
Note Submitter: freddy ---- hi, im storing pdf files in an sql database as per below. The store seems to work fine, however I am trying to retrieve and download or display the file from the sql data and it fails as a corrupt pdf file to retrieve i am just selecting from the database, changing content type and echoing data - eg below. Any ideas why this wouldnt work>? header("Content-Disposition:attachment;filename=$filename"); echo $data; Hi All, I was trying to insert PDF in MSSQL image datatype and had a worst time figuring out how to add PDF without encoding it with base64_encode. Encoding/decoding works best but it was conflicting with other existing PDFs in database as they weren't encoded. The solution is to create hex string and the Trick is *NOT* to use quotes in query. <?php $FileName = $_FILES['pdffile']['tmp_name']; $dataString = file_get_contents($FileName ); $arrData = unpack("H*hex", $dataString); $hexdata = "0x".$arrData['hex']; ?> Query: $sql = "insert into docs(pdfname, pdfdoc) values('$pdfname', $hexdata) Hope this helps to someone.... Cheerzz

« previous php.notes (#172576) next »