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