|
View:
New views
2 Messages
—
Rating Filter:
Alert me
|
|
|
Convert PDF to and From Oracle ErrorI have been trying to load PDF files into Oracle using Coldfusion and download them again and it seems the data is corrupt (thatâs the error message I get when I download it). The files seem to load properly (as byte array) it's when I try to doanload them is when I get the corrupted data error. Any help on what is going on/what the problem is? Here is my code/table: CREATE TABLE TBL ( USERID NUMBER(10), DEPARTDOC BLOB ) <!--- 1.cfm ---> <form action="2.cfm" method="POST" enctype="multipart/form-data"> File Name: <input name="FileName" type="file"> <input name="Submit" type="submit" value="Save"> </form> <!--- 2.cfm ---> <cfset Directory_Path = GetDirectoryFromPath(GetTemplatePath())> <cfif IsDefined("Form.Submit") AND Trim(form.FileName) NEQ ""> <cftry> <cffile action="upload" filefield="form.FileName" destination="#Directory_Path#" nameconflict="makeunique" accept="application/iso-8859-1, application/pdf"> <cffile action = "readbinary" file = "#Directory_Path##cffile.serverFile#" variable="file_blob"> <cfquery name="upload" datasource="dsn"> INSERT INTO TBL ( USERID, DEPARTDOC) VALUES ( 3, <cfqueryparam value="#file_blob#" cfsqltype="cf_sql_blob"> ) </cfquery> <cfcatch type="application"> Error... </cfcatch> </cftry> </cfif> <!--- 3.cfm ---> <cfheader name="content-disposition" value="attachment; filename=myFile.pdf"> <cfquery name="q" datasource="dsn"> select DEPARTDOC from TBL where userid = 2 </cfquery> <cfcontent type="application/iso-8859-1, application/pdf" variable="#q.DEPARTDOC#"> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/sql/message.cfm/messageid:3247 Subscription: http://www.houseoffusion.com/groups/sql/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.6 |
|
|
Re: Convert PDF to and From Oracle ErrorOk, thanks to this article: http://awads.net/wp/2006/02/21/lobs-gotcha-in-coldfusion/ I found the problem...which was not in the code, it was a setting in CF Administrator. The jist of the link/article is there is under the Data Source where your query is pointing to, under advanced settings there is an option to enable Blob and Clob. You must enabled. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists Archive: http://www.houseoffusion.com/groups/sql/message.cfm/messageid:3249 Subscription: http://www.houseoffusion.com/groups/sql/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.6 |
| Free embeddable forum powered by Nabble | Forum Help |