Storing and Retrieving PDFs from DB
ColdFusion 8.0.1 E (soon to be 9). Oracle 10g.
I am trying to store PDFs in the database and then retrieve them. So far storing them seems to go okay. But when I retrieve them I get an output that is just binary garbage.
Here is how I put it in the db:
<cffile action="readbinary" file="e:\pdfstorage\my.pdf" variable="testing">
<cfquery name="pdfTest" datasource="#application.datasource#">
update pdf_data
set thePDF = <cfqueryparam value="#testing#" cfsqltype="cf_sql_blob">
where PDFIDX = 1
</cfquery>
Of course the PDFIDX would change based on other code. Basically we have a form that is filled in and stored and then a PDF is attached. Right now they are just storing them in the pdfstorage but they want them in the database instead.
To retrieve I am doing this:
<cfquery name="pdfTest" datasource="#application.datasource#">
SELECT thePDF
FROM pdf_data
WHERE PDFIDX = 1
</cfquery>
<cfcontent type="application/pdf" variable="#pdfTest.thePDF#" reset="yes">
My output looks like this:
%PDF-1.5 %���� 465 0 obj <> endobj 477 0 obj <>/Filter/FlateDecode/ID[<633FD514E1E0FD0B97BAD1F9EEAC7F53><16186C0CAA988247B742A0375C859E99>]/Index[465 19]/Info 464 0 R/Length 69/Prev 31457/Root 466 0 R/Size 484/Type/XRef/W[1 2 1]>>stream h�bbd ``b`Z $ YA� �`� �m �JA, ! �
HELP!
