Cold Fusion CFfile issue

Posted on 2007-08-08
Last Modified: 2013-12-24
I have written an upload routine that will take Word Doc and upload to the file server. Once it is there it needs to be written to the SQL db.

It is uploading fine to the server but I am getting the following error when it tries to write the object to the db

"ByteArray objects cannot be converted to strings. "

Here is my code
<cffile action="upload"

              The file is on the web server now. Read it as a binary
              and put the result in the ColdFusion variable file_blob
                action = "readbinary"
                file = "D:\Inetpub\wwwroot\\wwwroot\testarea\Upload\#cffile.serverFile#"

              Insert the ColdFusion variable file_blob
              into the table, making sure to select
              cf_sql_blob as the sql type.
            <cfquery name="q" datasource="aboms">
                insert into tblupload_test (file) <!!!!!!*****Line where error is occuring.
                values (#file_blob#)


              No  need to keep the file on the webserver
              because it was just stored in the database. So,
              delete it from the folder.

            File successfully saved.
Question by:linder76
    LVL 9

    Accepted Solution

    When I did this I had to convert the blob to base64 to save it:

    <cfset data64 = toBase64(file_blob)>

    Then when I retrieve it, convert it back to binary

    <cfset base64version = #query.flieBlob#>
    <cfset binaryversion = #tobinary(base64version)#>
    LVL 9

    Expert Comment

    Did this work for you?  Or do you still need assistance?
    LVL 1

    Expert Comment

    Forced accept.

    EE Admin

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
    I've been asked to discuss some of the UX activities that I'm using with my team. Here I will share some details about how we approach UX projects.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

    755 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now