• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 463
  • Last Modified:

Can I upload an Image from a URL using <cffile?

Hello,

I would like to upload an image to my server from a URL using <cffile or any other means.  In other words, in the filefield, I was trying to put in a url like 'www.example.com/images/testimage.jpg'

However, I'm receiving an error 'The form field testImage did not contain a file' ..

What I'm doing is injecting the URL into a hidden form field and then submitting that form to <cffile.

Any ideas??

Thanks!!!!!!!
0
stracqan
Asked:
stracqan
  • 2
1 Solution
 
_agx_Commented:
Cffile can only manipulate files accessible on the local server. To grab an image from a remote url use CFHTTP or one of the image functions/tags. Both ImageNew() and CFIMAGE can read a url image. Then you can save the image object locally.  Assuming you have permission to use the image of course.



0
 
_agx_Commented:
CFHTTP
http://stackoverflow.com/questions/1536815/convert-an-image-from-cfhttp-filecontent-to-binary-data-with-coldfusion/1537433#1537433

IMAGENEW/CFIMAGE
http://livedocs.adobe.com/coldfusion/8/functions_h-im_34.html
<!--- This example shows how to create a ColdFusion image from a URL. --->
<cfset myImage = ImageNew("http://www.google.com/images/logo_sm.gif")>
<cfset ImageWrite(myImage,"google_via_imagenew.png")>
0
 
stracqanAuthor Commented:
As always _agx_, thank you!!!!! ..

(PS The URL is coming from an online Image Editor that sends a responce back to my site via a URL and in their terms of service they grant permission to acess the file in order to save locally.  Thanks for making sure I'm doing something cosher!!)
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now