ByteArray objects cannot be converted to strings
I am trying to manage images using cf and mysql. What a pain! My SQL doesn't play nice with images so I'm finding out.
Here is what I have done. I have blobs enabled in mysol admin. Now that I did that, I can't just read the image values I uploaded to the server, I have to read a byteArray. How do I do this??
This is the code giving me a problem:
<cfif projMan.thumb is true>
#toString(thumb)#
</cfif>
My cfif is throwing this error.
I also need it to be read if I update a record.. this is my insert update code:
<cffile Accept="image/*" action = "upload" Destination="D:\wwwroot\mysite\images\contentfile\" fileField = "MYFile" nameConflict = "overwrite">
<cfset uploadedfile = cffile.serverfile>
<cfif form.id EQ 0>
<cfquery name="InsertDetails" datasource="#sitedatasource#">
INSERT INTO recipes
(title, Body, thumb, descript, categoryID)
VALUES
(<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.title#">,
<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.Body#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadedfile#">,
<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.descript#">,
<cfqueryparam value="#form.categoryID#" cfsqlType="CF_SQL_INTEGER">)
</cfquery>
<cfelse>
<cfquery name="UpdateDetails" datasource="#sitedatasource#">
UPDATE recipes
SET
recipes.title=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.title#">,
recipes.Body=<cfqueryparam cfsqltype="cf_sql_longvarchar" value="#form.Body#">,
<cfif uploadedfile is true>
recipes.thumb=<cfqueryparam cfsqltype="cf_sql_varchar" value="#uploadedfile#">,
</cfif>
recipes.descript=<cfqueryparam cfsqltype="cf_sql_varchar" value="#form.descript#">,
recipes.CategoryID=<cfqueryparam value="#form.categoryID#" cfsqlType="CF_SQL_INTEGER">
WHERE recID = <cfqueryparam value="#form.ID#" cfsqlType="CF_SQL_INTEGER">
</cfquery>
</cfif>
Can anyone help me out? I'm hoping this is a simple solution.. I have been at this for 2 days now, and this is my last issue. It is also my first time using mysql for image management.
Thank you.
