Flickr HTML form upload

Below is a Flickr upload script i've been playing around with. You'll notice that im using <CFHTTP> to post the data. This is so that you can insert the fields into another form, otherwise if you want you can post the form fields direct to http://www.flickr.com/tools/uploader_go.gne.

For more information on the Flickr Upload Api click here.

<cfset flickrEmail = "" />
<cfset flickrPassword = "" />


<cfif NOT isDefined("form.photo")>
   <form action="flickr.cfm" method="post" enctype="multipart/form-data">
   
      <table border="1">
         <tr><td>photo:</td><td><input type="file" name="photo"></td></tr>
         <tr><td>title:</td><td><input type="text" name="title"> (optional)</td></tr>
         <tr><td>description:</td><td><input type="text" name="description"> (optional)</td></tr>
         <tr><td>tags:</td><td><input type="text" name="tags"> (optional)</td></tr>
         <tr><td>is_public:</td><td><input type="text" name="is_public"> (optional 1 or 0)</td></tr>
         <tr><td>is_friend:</td><td><input type="text" name="is_friend"> (optional 1 or 0)</td></tr>
      
         <tr><td>is_family:</td><td><input type="text" name="is_family"> (optional 1 or 0)</td></tr>
         <tr><td>&nbsp;</td><td><input type="checkbox" name="async" value="1"> Async Mode</td></tr>
         <tr><td>&nbsp;</td><td><input type="submit" value="post it"></td></tr>
      </table>
      
   </form>
<cfelse>
   <cftry>
      <cfhttp url="http://www.flickr.com/tools/uploader_go.gne" method="post">
         <cfhttpparam name="email" value="#flickrEmail#" type="formfield" />
         <cfhttpparam name="password" value="#flickrPassword" type="formfield" />
         <cfhttpparam name="photo" file="#form.photo#" type="file" />
         <cfhttpparam name="title" value="#form.title#" type="formfield" />
         <cfhttpparam name="description" value="description" type="formfield" />
         <cfhttpparam name="tags" value="#form.tags#" type="formfield" />
         <cfhttpparam name="is_public" value="#form.is_public#" type="formfield" />
         <cfhttpparam name="is_friend" value="#form.is_friend#" type="formfield" />
         <cfhttpparam name="is_family" value="#is_family#" type="formfield" />
      </cfhttp>
      <!--- The returned XML --->
      <cfdump var="#xmlParse(cfhttp.FileContent)#" />
      <cfcatch>
         <!--- If there was a problem --->
         <cfdump var="#cfcatch#" />
      </cfcatch>
   </cftry>
</cfif>

Posted: 27-Jun-2005

View: 5711

Permalink: here

Comments

Andy,

Have you been successful in using the new yahoo authentication and upload with ColdFusion? Looks like the only way to get a auth token is by a user opening a browser. Doesn't look like they've left anyway for an automated system to upload images without user intervention.

#1 Christopher Wigginton
06/Dec/05 7:48 AM

Hi,

i am trying to do something similar. I have a website with no scripting capabilities. I am not sure I think you are using ColdFusion. If ColdFusion is part of a proprietary thing then this is not working with my website server. So what I was looking into is if I could just post an image file through a form to the flickr site but from a form that is in my website.

Is this possible? how?

Encouragements,

cordoval@gmail.com

#2 luis
28/Mar/08 6:01 AM