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

Getting a file from another website

New Here ,
May 07, 2009 May 07, 2009

Hello,

I am trying to get a image from another website. This is not illegal practice that I am trying to conduct. I develop real estate websites and I am just trying to get a list of home images from our provider. I am trying to use cffile (copy) to copy the image from their site to my site.

<cffile action="copy" source="http://www.theprovidersite.com/IMLS98393231B.jpg" destination = "path_to_my_server/file_name.jpg">

I just keep getting a bunch of errors. Does anyone know how to do this. I could just go and download them one at a time, but I would rather just loop through an array and let the server grab them.

Thanks

Basically I just want to read an image on another site and copy that image to my webserver. Anyone know how to do this. Thanks again!

TOPICS
Getting started
1.3K
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 07, 2009 May 07, 2009

<cffile...> is for file system access and to work properly you must provide a proper file system path.  I.E. "c:\\aDirectory\aFile" OR "\\aServer\aDirectory\aFile"  For the latter to work the ColdFusion service|daemon will need to be properly configured to have file system access to the remote server.

To use a HTTP URL you should use the tag designed for that protocol, aka <cfhttp...>

See the documentation on how to use the <cfhttp...> protocol to retreive binary objects such as images.

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
Advocate ,
May 07, 2009 May 07, 2009

Hi,

It would seem that you might want to look at cfhttp for this action.

<cfhttp method="get" url="http://www.url.com.path/to/image/image.jpg" file="path/to/file/on/server/myjpg.jpg" />

<html>

     <head>

          <title>Testing CFHTTP</title>

     </head>

     <body>

          <img src="path/to/file/on/server/myjpg.jpg">

     </body>

</html>

ColdFusion will save a copy of the image on your server, where noted in the file attribute.

There might be better ways of doing this but I did test this with an image on one of my sites and it worked.

edit: pressed submit as Ian's response came through. sorry for the dupe.

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
Community Expert ,
May 08, 2009 May 08, 2009

<cfhttp

method="get" url="http://www.digitalphotoartistry.com/rose1.jpg" file="RoseByAnotherName.jpg" path="C:\ColdFusion8\wwwroot\images" />

<img src="/images/RoseByAnotherName.jpg">

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
LEGEND ,
May 08, 2009 May 08, 2009

Instead of copying the images to your server, you could always use the img tag to display the originals.

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
Community Expert ,
May 08, 2009 May 08, 2009
LATEST
Instead of copying the images to your server, you could always use the img tag to display the originals.

<img src="http://www.somebodyElse.com/image.jpg"> is generally considered sneaky, and bad etiquette. 

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