Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Copy file from one server to another

Guest
May 11, 2011 May 11, 2011

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">

1.6K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
May 11, 2011 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
May 12, 2011 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
May 12, 2011 May 12, 2011
LATEST

Thanks. The following code worked for me.

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources