<!--- Start by defining the default CFHttp tags attributes. These are the attributes we are going to use no matter what. ---> <cfset objAttributes = { <!--- The method. ---> Method = "GET", <!--- The target URL. ---> URL = ( "http://farm1.static.flickr.com/201/" & "516472664_cd4284abe1.jpg?v=0" ), <!--- Set the broadcasted user agent. ---> UserAgent = CGI.http_user_agent, <!--- How we want to handle the CFHttp result. ---> Result = "objGet" } /> <!--- Now that we have our basic CFHttp attributes configured, let's check to see if we are downloading the response or capturing the response binary to a file. ---> <cfif blnDownload> <!--- Now that we know we are downloading, we need to set additional CFHttp tag attributes. ---> <!--- Tell ColdFusion to grab the target URL as a binary so that we can write the binary data to disk. ---> <cfset objAttributes.GetAsBinary = "yes" /> <!--- Define the storage directory. ---> <cfset objAttributes.Path = ExpandPath( "./" ) /> <!--- Define the storage file. ---> <cfset objAttributes.File = "lady.jpg" /> </cfif> <!--- ASSERT: At this point we have our attribute collection struct fully defined regardless of whether or not we are downloading the target file. ---> <!--- Execute the CFHttp tag. ---> <cfhttp attributecollection="#objAttributes#" /> <!--- Dump out the result. ---> <cfdump var="#objGet#" label="CFHttp Results" />