User Guide

Table Of Contents
994 Chapter 40: Interacting with Remote Servers
To get a binary file and save it:
1.
Create a ColdFusion page with the following content:
<cfhttp
method="Get"
url="http://www.macromedia.com/macromedia/accessibility/images/
spotlight.jpg"
path="c:\temp"
file="My_SavedBinary.jpg">
<cfoutput>
#cfhttp.MimeType#
</cfoutput>
2.
(Optional) Replace the value of the url attribute with the URL of a binary file that you want
to download.
3.
(Optional) Change the path from C:\temp to a path on your hard drive.
4.
Save the file as save_binary.cfm in the myapps directory under your web_root and open it in the
web browser to view the MIME type.
5.
(Optional) Verify that the binary file now exists at the location you specified in the path
attribute.
Reviewing the code
The following table describes the code and its function:
Creating a query object from a text file
You can create a query object from a delimited text file by using the cfhttp tag and specifying
method="Get" and the name attribute. This is a powerful method for processing and handling
text files. After you create the query object, you can easily reference columns in the query and
perform other ColdFusion operations on the data.
ColdFusion processes text files in the following manner:
You can specify a field delimiter with the delimiter attribute. The default is a comma.
If data in a field might include the delimiter character, you must surround the entire field with
the text qualifier character, which you can specify with the
textqualifier attribute. The
default text qualifier is the double-quotation mark (").
The textqualifier="" specifies that there is no text qualifier. If you use
textqualifier="""" (four " marks in a row), it explicitly specifies the double-quotation mark
as the text qualifier
.
Code Description
<cfhttp
method="Get"
url="http://www.macromedia.com/macromedia/
accessibility/images/spotlight.jpg"
path="c:\temp"
file="My_SavedBinary.jpg">
Get a binary file and save it in the path
and
file specified.
<cfoutput>
#cfhttp.MimeType#
</cfoutput>
Display the MIME type of the file.