Question
file corrupted after downloaded from SQL table
I'm trying to download a file which is saved in the SQL table
as base64 string and save it on the webserver. It works with the
file size less than 45K. Beyond that, file got corrupted. Can
somebody help me solve this issue? Thanks.
PS: We are using MX 6.1
Code:
<cfquery name="file" DATASOURCE="#application.adjsource#" USERNAME="#application.adjuser#" PASSWORD="#application.adjword#">
SELECT a.keyno,a.filename,a.notes,a.bindata
FROM datastore a
WHERE a.keyno = 123
</cfquery>
<cfset filepath = getdirectoryfrompath(getcurrenttemplatepath()) & 'temp\#file.filename#'>
<cfset tmpfile= tobinary(file.bindata)>
<cffile action="write" nameconflict="overwrite" addnewline="yes" output="#tmpfile#" file="#filepath#">
PS: We are using MX 6.1
Code:
<cfquery name="file" DATASOURCE="#application.adjsource#" USERNAME="#application.adjuser#" PASSWORD="#application.adjword#">
SELECT a.keyno,a.filename,a.notes,a.bindata
FROM datastore a
WHERE a.keyno = 123
</cfquery>
<cfset filepath = getdirectoryfrompath(getcurrenttemplatepath()) & 'temp\#file.filename#'>
<cfset tmpfile= tobinary(file.bindata)>
<cffile action="write" nameconflict="overwrite" addnewline="yes" output="#tmpfile#" file="#filepath#">