Posting Information
Besides allowing you to retrieve information, you can also post
information to remote web sites with cfhttp
. By
setting the method
attribute to
Post
, you can use cfhttp
to
pass information such as files, URLs, CGI variables, cookies, and
form fields to other web applications, such as a ColdFusion page or
CGI program, on a remote server. cfhttp
post
operations are considered two-way transactions because they pass
variables to remote applications, which usually process the input and
return data.
When performing cfhttp
post operations, you have
to specify an additional tag, cfhttpparam
, for
each value you are passing in the transaction. In other words, if you
are using cfhttp
to post two form-field variables
to a remote form, you need to use two cfhttpparam
tags in conjunction with the cfhttp
tag. By
specifying the variable type in each cfhttpparam
tag, ColdFusion allows you to interact with applications that require
multipart form data, such as cookies, text, and file fields, in the
same operation. Note that cfhttpparam
tags are
always nested within a cfhttp
tag. Here is the
syntax for using the cfhttpparam
tag:
<cfhttpparam name="name
" type="transaction_type
" value="variable_value
" encoded="Yes|No" mimetype="MIME_type[and_charset]
" file="filename
">
The type
attribute specifies the type of
information you are passing to the remote application. Possible
values are:
-
Body
Body of an HTTP request. Only one
cfhttpparam
tag withtype="Body"
can be used percfhttp
request. ...
Get Programming ColdFusion MX, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.