Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
cam_pdx #1
CFMX blob insertion to MySQL
I am trying to use CFMX to store a binary (blob) into a MySQL db. Using MySQL
Control Center (GUI interface to the db), I have manually placed a couple image
files into the db for reference (a jpg and a gif, though my project will
ultimately store ppt). When looking at the abbreviated data representation of
these files (the file content) in Control Center, I see: for the jpg: ???? for
the gif: GIF89a No other characters appear in the abbreviated data
representation, but opening one of the records in the GUI displays the image as
an image. So far I have tried gathering the file info via: <cfhttp
url='#appWebPath#temp_sfiles/#session.userid#/#name#' method='get' /> ...and
<cffile action='readbinary'
file='#appFullPath#temp_sfiles/#session.userid#/#name#'
variable='sfile_content'> I have tried many ways of converting the data in
#sfile_content# so that the database will accept it. I was never able to do
anything with it (I would get a variety of errors). Upon dumping cfhttp and
displaying cfhttp.filecontent, for the first time I noticed something familiar.
The first few characters of cfhttp.filecontent matched the abbreviated
displays I mentioned above. So I started working with cfhttp.filecontent.
It's still not inserting into the db, but it looks like I may have finally
tapped into the correct source of data in something close to the correct form.
My query: <cfquery datasource='#dsn#'> INSERT INTO ef_supportfiles
( file_id, sfile_name, sfile_mimetype, sfile_content )
VALUES ( #rsMaxFileID.max_file_id#, <cfqueryparam
cfsqltype='cf_sql_varchar' value='#sfile_name#'>, <cfqueryparam
cfsqltype='cf_sql_varchar' value='#sfile_mimetype#'>, <cfqueryparam
cfsqltype='cf_sql_blob' value='#tobase64(tobinary(cfhttp.filecontent))#'>
) </cfquery> Variations to the last line of the query and the resulting
errors: <cfqueryparam cfsqltype='cf_sql_blob'
value='#tobase64(tobinary(cfhttp.filecontent))#'> gets: 'must be a base-64
encoded string' <cfqueryparam cfsqltype='cf_sql_blob'
value='#tobase64(cfhttp.filecontent)#'> gets: 'Could not convert the value of
type class java.io.ByteArrayOutputStream to binary' <cfqueryparam
cfsqltype='cf_sql_blob' value='#cfhttp.filecontent#'> gets: 'Unknown Types
value' #cfhttp.filecontent# gets: 'No value specified for parameter 3 '
#tobase64(cfhttp.filecontent)# gets: 'Could not convert the value of type
class java.io.ByteArrayOutputStream to binary' #tobinary(cfhttp.filecontent)#
gets: 'must be a Base-64 encoded string' Any ideas would be *greatly*
appreciated. Thank you. Todd
cam_pdx Guest
-
insert blob in MySQL (CF_SQL_BLOB) not working
I've read the post about "insert blob in oracle (CF_SQL_BLOB) not working" and followed the solution. The only difference here is that I am dealing... -
Date insertion problems MySQL
I am currently trying to update a mysql database with a date entered using a form. However when I look at the database the date always reads... -
Read blob from mysql
Hello, I do have a mysql database with a BLOB column. What is the proprest way to read this column ? Thx, Thierry -
PHP, MySQL, Blob data type
I'm going to store image files in Blob data field. Does anyone know if there is an easy way to use Dreamweaver (or Dreamweaver Extension) to display... -
[PHP] How do I dump a blob or text into a mySQL Database?
Dan Anderson wrote: Is $buffer empty? I would start there. - Brad



Reply With Quote

