For the complete experience, please enable JavaScript in your browser. Thank you!

  • Creative Cloud
  • Photoshop
  • Illustrator
  • InDesign
  • Premiere Pro
  • After Effects
  • Lightroom
  • See all
  • See plans for: businesses photographers students
  • Document Cloud
  • Acrobat DC
  • eSign
  • Stock
  • Elements
  • Marketing Cloud
  • Analytics
  • Audience Manager
  • Campaign
  • Experience Manager
  • Media Optimizer
  • Target
  • See all
  • Acrobat Reader DC
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player
  • All products
  • Creative Cloud
  • Individuals
  • Photographers
  • Students and Teachers
  • Business
  • Schools and Universities
  • Marketing Cloud
  • Document Cloud
  • Stock
  • Elements
  • All products
  • Get Support
    Find answers quickly. Contact us if you need to.
    Start now >
  • Learn the apps
    Get started or learn new ways to work.
    Learn now >
  • Ask the community
    Post questions and get answers from experts.
    Start now >
    • About Us
    • Careers At Adobe
    • Investor Relations
    • Privacy  |  Security
    • Corporate Responsibility
    • Customer Showcase
    • Events
    • Contact Us
News
    • 3/22/2016
      Adobe Summit 2016: Are You An Experience Business?
    • 3/22/2016
      Adobe Announces Cross-Device Co-op to Enable People-Based Marketing
    • 3/22/2016
      Adobe and comScore Advance Digital TV and Ad Measurement
    • 3/22/2016
      Adobe Marketing Cloud Redefines TV Experience
Interacting with Remote Servers / 

Using the cfhttp Post method

Adobe Community Help


Applies to

  • ColdFusion

Contact support

 
By clicking Submit, you accept the Adobe Terms of Use.
 

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, 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 the cfhttp tag, the page that receives the Post does not, itself, display anything.

Pass variables to a ColdFusion page

  1. Create a ColdFusion page with the following content:

    <html>
    <head>
    <title>HTTP Post Test</title>
    </head>
    <body>
    <h1>HTTP Post Test</h1>
    <cfhttp method="Post"
    url="http://127.0.0.1:8500/myapps/post_test_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="twriter@adobe.com"
    name="emailaddress">
    <cfhttpparam type="File"
    name="myfile"
    file="c:\pix\trees.gif">
    </cfhttp>
    <cfoutput>
    File Content:<br>
    #cfhttp.filecontent#<br>
    Mime Type:#cfhttp.MimeType#<br>
    </cfoutput>
    </body>
    </html>

  2. Replace the path to the GIF file to a path on your server (just before the closing cfhttp tag).
  3. Save the file as post_test.cfm in the myapps directory under your web_root.

Note: Write a page to view the variables, as described in next procedure.

Reviewing the code

The following table describes the code and its function:

Code

Description

 

<cfhttp method="Post" url="http://127.0.0.1:8500/myapps/post_test_server.cfm">

 

Post an HTTP request to the specified page.

 

<cfhttpparam type="Cookie" value="cookiemonster" name="mycookie6">

 

Send a cookie in the request.

 

<cfhttpparam type="CGI" value="cgivar " name="mycgi">

 

Send a CGI variable in the request.

 

<cfhttpparam type="URL" value="theurl" name="myurl">

 

Send a URL in the request.

 

<cfhttpparam type="Formfield" value="twriter@adobe.com" name="emailaddress">

 

Send a Form field in the request.

 

<cfhttpparam type="File" name="myfile" file="c"\pix\trees.gif">

 

Send a file in the request. The </> tag ends the http request.

 

<cfoutput>
File Content:<br>
#cfhttp.filecontent#<br>

 

Display the contents of the file that the page that is posted to creates by processing the request. In this example, the contents is the output from the cfoutput tag in server.cfm.

 

Mime Type: #cfhttp.MimeType#<br>
</cfoutput>

 

Display the MIME type of the created file.

View the variables

  1. Create a ColdFusion page with the following content:

    <html>
    <head><title>HTTP Post Test</title> </head>
    <body>
    <h1>HTTP Post Test</h1>
    <cffile destination="C:\temp\"
    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>
    </body>
    </html>

  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:

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 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. This page does not display the results. 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.

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="ColdFusion">
</cfhttp>
<cfoutput>
Response Mime Type: #cfhttp.MimeType#<br>
Response Length: #len(cfhttp.filecontent)# <br>
Response Content: <br>
#htmlcodeformat(cfhttp.filecontent)#<br>
</cfoutput>

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License  Twitter™ and Facebook posts are not covered under the terms of Creative Commons.

Legal Notices   |   Online Privacy Policy

Choose your region United States (Change)   Products   Downloads   Learn & Support   Company
Choose your region Close

Americas

Europe, Middle East and Africa

Asia Pacific

  • Brasil
  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Cyprus - English
  • Česká republika
  • Danmark
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Greece - English
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • Malta - English
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • Southeast Asia (Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam) - English
  • 台灣

Commonwealth of Independent States

  • Includes Armenia, Azerbaijan, Belarus, Georgia, Moldova, Kazakhstan, Kyrgyzstan, Tajikistan, Turkmenistan, Ukraine, Uzbekistan

Copyright © 2016 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy | Cookies

AdChoices