Copy link to clipboard
Copied
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!
Copy link to clipboard
Copied
<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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
<cfhttp
method="get" url="http://www.digitalphotoartistry.com/rose1.jpg" file="RoseByAnotherName.jpg" path="C:\ColdFusion8\wwwroot\images" />
<img src="/images/RoseByAnotherName.jpg">
Copy link to clipboard
Copied
Instead of copying the images to your server, you could always use the img tag to display the originals.
Copy link to clipboard
Copied
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.