User Guide

Table Of Contents
998 Chapter 40: Interacting with Remote Servers
2.
Replace C:\temp\ with an appropriate directory path on your hard drive.
3.
Save the file as post_test_server.cfm in the myapps directory under your web_root.
4.
View post_test.cfm in your browser and look for the file in C:\temp\ (or your replacement
path).
Reviewing the code
The following table describes the code and its function:
To return results of a CGI program:
The following code runs a CGI program search.exe on a website and displays the results,
including both the MIME type and length of the response. The search.exe program must expect a
“search” parameter.
<cfhttp method="Post"
url="http://www.my_favorite_site.com/search.exe"
resolveurl="Yes">
<cfhttpparam type="Formfield"
name="search"
value="Macromedia ColdFusion">
</cfhttp>
Code Description
<cffile destination="C:\temp\"
nameconflict="Overwrite"
filefield="Form.myfile"
action="Upload"
attributes="Normal">
Write the transferred document to a file on the server.
You send the file using the
cfhttpparam type="File"
attribute, but the receiving page gets it as a Form
variable, not a File variable. This
cffile tag creates
File variables, as follows.
<cfoutput>
Output information. The results are not displayed by
this page. They are passed back to the posting page in
its
cfhttp.filecontent variable.
The URL variable is: #URL.myurl# <br>
Output the value of the URL variable sent in the HTTP
request.
The Cookie variable is:
#Cookie.mycookie# <br>
Output the value of the Cookie variable sent in the
HTTP request.
The CGI variable is: #CGI.mycgi# <br>
Output the value of the CGI variable sent in the HTTP
request.
The Form variable is:
#Form.emailaddress#. <br>
Output the Form variable sent in the HTTP request.
You send the variable using the
type="formField"
attribute but the receiving page gets it as a Form
variable.
The file was uploaded to
#File.ServerDirectory#\#File.
ServerFile#.
</cfoutput>
Output the results of the cffile tag on this page. This
time, the variables really are File variables.