Skip to main content
May 11, 2011
Question

Copy file from one server to another

  • May 11, 2011
  • 2 replies
  • 1648 views

I have two intranet sites on two different servers. There is an image on the site1 which I would like to copy to site2. How do I do that ?

Here is my code.

<cfset image1Ext = Right(firstStoryImg, 3)>

where firstStoryImg evaluates to http://mycompany.com/site1/images/firstImage.gif

The following code is throwing "The cause of this exception  was: java.io.FileNotFoundException:" error.

<cffile action="copy" source="#firstStoryImg#" destination="/folder/Images/image1.#image1Ext#" nameconflict="overwrite">

    This topic has been closed for replies.

    2 replies

    Owainnorth
    Inspiring
    May 12, 2011

    What he said.

    In addition:

    <cfset image1Ext = Right(firstStoryImg, 3)>

    What happens if someone uploads a (valid) .jpeg file? You'll land yourself with a .peg file, that's what.

    May 12, 2011

    Thanks. The following code worked for me.

    <cfhttp url="#firstStoryImg#" path="#ExpandPath("\usaNewsImages\")#" resolveurl="No" timeout="120"></cfhttp>

    ilssac
    Inspiring
    May 11, 2011

    You can't use <cffile...> to copy an HTTP url.  You need to use <cfhttp...> for an HTTP url.  With <cffile...> you are expected to use a file system path.