Use the Post method to send cookie, form field, CGI, URL, and file variables to a specified ColdFusion page or CGI program for processing. For Post operations, you must use the cfhttpparam tag for each variable you want to post. The Post method passes data to a specified ColdFusion page or an executable that interprets the variables being sent and returns data.
For example, when you build an HTML form using the Post method, you specify the name of the page to which form data is passed. You use the Post method in cfhttp in a similar way. However, with cfhttp, the page that receives the Post does not, itself, display anything.
<html>
<head>
<title>HTTP Post Test</title>
</head>
<body>
<H1>HTTP Post Test</H1>
<cfhttp method="Post"
url="http://127.0.0.1/myapps/server.cfm">
<cfhttpparam type="Cookie"
value="cookiemonster"
name="mycookie6">
<cfhttpparam type="CGI"
value="cgivar "
name="mycgi">
<cfhttpparam type="URL"
value="theurl"
name="myurl">
<cfhttpparam type="Formfield"
value="wbfreuh@macromedia.com"
name="emailaddress">
<cfhttpparam type="File"
name="myfile"
file="c:\testImage.gif">
</cfhttp>
<cfoutput>
File Content:<br>
#cfhttp.filecontent#<br>
<br>
Mime Type: #cfhttp.MimeType#<br>
</cfoutput>
</body>
</html>
myapps under your Web root directory.The following table describes the code and its function:
<cffile destination="C:\temp\Junk" nameconflict="Overwrite" filefield="Form.myfile" action="Upload" attributes="Normal"> <cfoutput> The URL variable is: #URL.myurl# <br> The Cookie variable is: #Cookie.mycookie6# <br> The CGI variable is: #CGI.mycgi#. <br> The Formfield variable is: #Form.emailaddress#. <br> The file was uploaded to #File.ServerDirectory#\#File.ServerFile#. </cfoutput>
server.cfm in myapps under your Web root directory.The following table describes the code and its function:
The following code runs the (theoretical) CGI program search.exe on the (equally theoretical) somesiteorother.com site 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.somesiteorother.com/search.exe"
resolveurl="Yes">
<cfhttpparam type="Formfield"
name="search"
value="Macromedia ColdFusion">
</cfhttp>
<cfoutput>
Response Mime Type: #cfhttp.MimeType#<br>
Response Length: #len(cfhttp.filecontent)# <br>
Response Content: <br>
#htmlcodeformat(cfhttp.filecontent)#<br>
</cfoutput>
LiveDocs comments are not longer enabled for ColdFusion 5.0. Please use one of the following resources instead.
ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting
Version 5.0