Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Alternative to CFFILE to write a text file?

Status
Not open for further replies.

jmk6281

Programmer
Joined
Jun 7, 1999
Messages
2
Location
US
My hosting company has CFFILE disabled (for security). I'm trying to test a program where I do a query of an Access database. I know CFFILE would then allow me to popular the data of this query into a .txt or .xls file where I could eventually have my client download it.

However, I'm stuck without CFFILE ability. Is there any other suggested way to populate a text fil(or excel) after a do a CFQUERY? I was looking at CFHTTP, but I'm not sure that would work.

Thanks!
 
Well, you could write a text file dynamically in ColdFusion every time the client downloaded it:
Code:
<cfquery name=&quot;myQuery&quot;>
   SELECT ID,Name,Code
   FROM myTable
</cfquery>

<cfcontent type=&quot;text/plain&quot; reset=&quot;Yes&quot;>
<cfheader name=&quot;Content-Disposition&quot; value=&quot;attachment;filename=myfile.txt&quot;>
ID,Name,Code
<cfoutput query=&quot;myQuery&quot;>#ID#,#Name#,#Code#
</cfoutput>
When the browser requests this .cfm page, the response from the server will be a text file called myfile.txt.
 
Unfortunately, they also have CFCONTENT (and CFDIRECTORY, CFOBJECT, CFREGISTRY, CFFILE) disabled. Yes, I should probably find a hosting company that allows full access, but I picked them just as I was getting started in Cold Fusion, and I did not realize that this would be an issue.

Any other ideas??? Or good CF Hosting companies?
 
You could do this without <CFCONTENT>, as long as you can use <CFHEADER>. Replace this code:
Code:
<cfcontent type=&quot;text/plain&quot; reset=&quot;Yes&quot;>
With this code:
Code:
<cfheader name=&quot;Content-Type&quot; value=&quot;text/plain&quot;>
In this case, though, any whitespace that has accumulated before you start the output will be included in the text file, so you'll want to minimize the extra white space as much as possible.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top