User Guide

234 Developing Web Applications with ColdFusion
<CFHTTP
METHOD="Get"
URL="http://maximus/downloads/quakestuff/q2_test.zip"
PATH="c:\quake2\install"
FILE="quake2beta.zip">
<CFOUTPUT>
#CFHTTP.MimeType#
</CFOUTPUT>
3. Change the URL to point to a binary file you want to download.
4. Change the path to point to a path on your hard drive.
5. Save the file as
savebinary.cfm in myapps under your Web root directory and view
it in your browser.
Code Review
Creating a Query from a Text File
Using the CFHTTP Get operation, you can create a query object from a delimited text
file. This is a powerful means for processing and handling generated text files. Once the
query object is created, it is very simple to reference columns in the query and perform
other ColdFusion operations on the data.
Text files are processed in the following manner:
You specify a delimiter with the DELIMITER attribute. If data in a field includes
the delimiter character, it must be quoted or qualified with some other
character, which you specify with the TEXTQUALIFIER attribute.
The first row of a text file is always interpreted as column headings, so that row
is skipped. If the first row doesn’t contain column headings, you’ll need to use
the COLUMNS attribute to specify headings so that you don’t lose the first row
data. You can also use the COLUMNS attribute to specify alternate heading text.
Just make sure that you enter an alternate for every column of data in the text
file.
Code Description
<CFHTTP
METHOD="Get"
URL="http://maximus/downloads/quakestuff/
q2_test.zip"
PATH="c:\quake2\install"
FILE="quake2beta.zip">
Get a binary file and save it in
the PATH and FILE specified.
<CFOUTPUT>
#CFHTTP.MimeType#
</CFOUTPUT>
Display the MIME type of the
file.