You use Get to retrieve text and binary files from a specified server. The examples below illustrate a few common GET operations.
| To retrieve a file and store it in a variable: |
<CFHTTP METHOD="Get"
URL="http://www.allaire.com/index.cfm"
RESOLVEURL="Yes">
<CFOUTPUT>
#CFHTTP.FileContent# <BR>
</CFOUTPUT>
getwebpage.cfm in myapps under your Web root directory and view it in your browser.
| Code | Description |
|---|---|
<CFHTTP METHOD="Get" URL="http://www.allaire.com/index.cfm" RESOLVEURL="Yes"> | Get the page specified in the URL and make the links absolute instead of relative.. |
<CFOUTPUT>
#CFHTTP.FileContent# <BR>
</CFOUTPUT>
|
Display the page, which is stored in the variable CFHTTP.FileContent, in the browser.
|
| To get a Web page and save it in a file: |
<CFHTTP
METHOD = "get"
URL="http://www.allaire.com/index.cfm"
PATH="c:\mine"
FILE="allaireindex.cfm">
c:\mine to point to a path on your hard drive.
savewebpage.cfm and view it in your browser.
| Code | Description |
|---|---|
<CFHTTP
METHOD = "get"
URL="http://www.allaire.com/index.cfm"
PATH="c:\mine"
FILE="allaireindex.cfm">
| Get the page specified in the URL and save it in the file specified in PATH and FILE. Note that when the PATH and FILE attributes are used, the RESOLVEURL attribute is ignored, even if present. |
| To get a binary file and save it: |
<CFHTTP
METHOD="Get"
URL="http://maximus/downloads/quakestuff/q2_test.zip"
PATH="c:\quake2\install"
FILE="quake2beta.zip">
<CFOUTPUT>
#CFHTTP.MimeType#
</CFOUTPUT>
savebinary.cfm in myapps under your Web root directory and view it in your browser.
| Code | Description |
|---|---|
<CFHTTP
METHOD="Get"
URL="http://maximus/downloads/quakestuff/
q2_test.zip"
PATH="c:\quake2\install"
FILE="quake2beta.zip">
| Get a binary file and save it in the PATH and FILE specified. |
<CFOUTPUT>
#CFHTTP.MimeType#
</CFOUTPUT>
| Display the MIME type of the file. |