Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

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

Posted on 2011-02-15
3
434 Views
Last Modified: 2012-05-11
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
Comment
Question by:stracqan
  • 2
3 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34903889
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
 
LVL 52

Accepted Solution

by:
_agx_ earned 500 total points
ID: 34903894
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
 

Author Closing Comment

by:stracqan
ID: 34903922
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question