Skip to main content
April 10, 2006
Answered

ToBase64

  • April 10, 2006
  • 9 replies
  • 1079 views
I am still having trouble with this tag. Any file over 46.8KB gets cut off to this size. Is there a size limitation for this tag?
This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer
I still have this problem. I had to move on to other stuff but will be coming back to this very soon.

"Check your datasource in CF administrator.
Make sure that you have CLOB and BLOB checked under "Advanced settings". "

I am using MSSQL and when making tables do not see the option for CLOB or BLOB. only Image and Text. The macromedia site had a table that showed no support for BLOB with MSSQL. Did I miss somthing? I would gladly use BLOB if I could.

Coldfusion supports BLOB and CLOB with MS SQL.

This is not set when you create a table, this is set when you create or edit a data source.

Do not use dreamweaver for this. Use the CF Administrator.
See http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000115.htm
to get started.

9 replies

BKBK
Community Expert
Community Expert
April 12, 2006
I think you should make the following modifications:

- fileField="uploadFile"
- destination="#ExpandPath(".")#\"

April 13, 2006
Thanks for yout time and help but the above change made no diffrence. I have been googling around for days, I am now looking into READTEXT and SET TEXTSIZE. It sounds like be database will cut output short. I am still having trouble I cant seem to get these to work in sql statements. Well back to the docs.
BKBK
Community Expert
Community Expert
April 12, 2006
Any file over 46.8KB gets cut off to this size. Is there a size limitation for this tag?
If there is, it will surely be much higher than 46 KB. I think the problem comes from elsewhere.

The following code runs successfully, execution time 80 ms. The result is

photo file length: 781.00 kB
photo file to base 64 length: 1,041.33 kB



April 12, 2006
Here is my bit of bad code:
<cffile action="upload" fileField="form.uploadFile" destination="#ExpandPath(".")#" nameConflict="OVERWRITE">
<cfdump var="#cffile#"><!--- output data for testing --->
<cffile action="readBinary" file="#file.serverDirectory#\#file.serverFile#" variable="myFile"><!--- read file into binary stream --->
<cfset tobase = ToBase64(myFile)>
<cfoutput>#decimalformat(Len(ToBase64(tobase))/1024)#</cfoutput> kB

<!--- <cfif cffile.fileSize LT 46000>--->
<cfquery name="insertFile" datasource="KFS"><!--- insert to DB --->
SET TEXTSIZE 1000000
INSERT INTO TestUpload(fileName, fileType ,subType, fileData, fileSize)
VALUES('#cffile.serverFile#','#cffile.contentType#','#cffile.contentSubType#','#tobase#','#cffile.fileSize#'
)
</cfquery>

I see using your output line that the tobase64 is working. But when I retrive it from the DB it is always 46.8KB. So the trouble must be in the DB. I have the table set to hold "text" and belive it should hold up to 2 gig? any ideas why my file is getting cut short?