Solved

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

Posted on 2011-02-15
3
421 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_
Comment Utility
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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

This is an updated version of a post made on my blog over 3 years ago. It is unfortunately, still very relevant as we continue to see both SQLi (SQL injection) and XSS (cross site scripting) attacks hitting some of the most recognizable website and …
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now