Solved

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

Posted on 2011-02-15
3
431 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Why am I getting a binary result from my query? 5 82
RETURN INFORMATION FROM COLDFSION CFC 1 67
Coldfusion Table display that allows inline edit 3 43
CSS HELP 6 88
Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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