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>

comments powered by Disqus