--- /dev/null
+<!---\rAJAX FileUploader for ColdFusion\rversion: 1.1.1\rfeedback: sid.maestre@designovermatter.com\r\r-----------update history----------------\r1.1.1 on 9/30/2010 by Martin Webb <martin[at]cubicstate.com>\r- Change function for Upload to returnformat equals JSON\r- local var scoping.\r1.1 on 9/9/2010 by Sid Maestre\r- Split Upload function to handle fallback uploads for browsers that don't support XHR data transfer\r--->\r<cfcomponent hint="I handle AJAX File Uploads from Valum's AJAX file uploader library">\r \r <cffunction name="Upload" access="remote" output="false" returntype="any" returnformat="JSON">\r <cfargument name="qqfile" type="string" required="true">\r\r <cfset var local = structNew()>\r <cfset local.response = structNew()>\r <cfset local.requestData = GetHttpRequestData()>\r \r <!--- check if XHR data exists --->\r <cfif len(local.requestData.content) GT 0>\r <cfset local.response = UploadFileXhr(arguments.qqfile, local.requestData.content)> \r <cfelse>\r <!--- no XHR data process as standard form submission --->\r <cffile action="upload" fileField="arguments.qqfile" destination="#ExpandPath('.')#" nameConflict="makeunique">\r <cfset local.response['success'] = true>\r <cfset local.response['type'] = 'form'>\r </cfif>\r \r <cfreturn local.response>\r </cffunction>\r \r \r <cffunction name="UploadFileXhr" access="private" output="false" returntype="struct">\r <cfargument name="qqfile" type="string" required="true">\r <cfargument name="content" type="any" required="true">\r\r <cfset var local = structNew()>\r <cfset local.response = structNew()>\r\r <!--- write the contents of the http request to a file. \r The filename is passed with the qqfile variable --->\r <cffile action="write" file="#ExpandPath('.')#/#arguments.qqfile#" output="#arguments.content#">\r \r <!--- if you want to return some JSON you can do it here. \r I'm just passing a success message --->\r <cfset local.response['success'] = true>\r <cfset local.response['type'] = 'xhr'>\r \r <cfreturn local.response>\r </cffunction>\r \r</cfcomponent>
\ No newline at end of file