Can ColdFusion upload a file to a different domain?

SiobhanElara used Ask the Experts™
We have a client that has three domains for three different properties (we'll call them,, and, but wants to administer all the content through one main admin on

I'm not having a problem with information that's contained in databases, especially since all the domains are hosted on the same server. My problem is with the extremely simple photo galleries on each domain (and by "simple" I mean the images names are merely retrieved with cfdirectory.)

Is there a way to upload an image from to I've never had to do anything like this before and can't seem to even retrieve the directory contents of from Would all this require cfftp instead?

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

It depends on the server.   I host myself and have open access between all my directories.  I could do this easily.   However, if you have a third party host and have three seperate accounts, then it would likely not be allowed for security.   If you have one account, with multiple domains, then ask your host if you can access the different directories.

Otherwise, then do as you suggest and use CFHTTP to pull the file over...
Staff IT Engineer
If you have control over BOTH the domains and servers, you can use CFHTTP to upload file from one server to another

<cfhttp url="" method="post">  
              <cfhttpparam name="file1" type="file" file="YOURFILEPATH ON" mimetype="image/jpeg" />  
              <cfhttpparam name="BecauseTheFileIsCorruptedWithoutThisField" type="formfield" value="" />  

--- Then ON B.COM, you can have code like - galleryCfhttp.cfm ----

<cfif structKeyExists(FORM, "File1")>
   <cfset UploadPath = 'Path On /images/gallery/' />
    <cffile action="upload" destination="#UploadPath#" nameconflict="overwrite" />  
You don't actually need to have control over both websites, you can pull images and files from any website.

Here is an example using CFTTP.  No parameters are needed.

After pulling the file over, this checks status and tests for existance.

<cfset  variables.imageURL = "">
 <cfset  variables.TempFile  = "c:\images\logo.jpg">

 <cfhttp url="#variables.imageURL#" path="#getDirectoryFromPath(variables.TempFile)#" file="#getFileFromPath(variables.TempFile)#" method="GET"></cfhttp>

 <cfif val(cfhttp.statusCode) is not 200>
    <cfthrow message="#cfhttp.statusCode#" detail="Download failed: #cfhttp.statusCode#" type="myError">	
 <cfif NOT fileExists(variables.TempFile)>
   <cfthrow message="File Not Downloaded" detail="Form file was not found in temp directory after download" type="myError">

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial