Reputation: 4488
I have a Backbone front-end that is sending restful calls with an uploaded file to a Coldfusion backend.
I need to know how to 'get at' the file once it has reached my CFC. Unfortunately i have some doubt as to whether the file is being sent at all, my POST goes off fine and returns a basic string from the CFC so i know that is working.
The POST payload looks like this
------WebKitFormBoundarymjCH1xJJ2D10ncj8
Content-Disposition: form-data; name="qqfile"; filename="Jellyfish.jpg"
Content-Type: image/jpeg
------WebKitFormBoundarymjCH1xJJ2D10ncj8--
I am using jquery FineUploader to send the request.
I am currently using this to try and pick up the file on the CFC end.
<cfcomponent displayname="import"
rest="true"
restPath="/import">
<cffunction name="import"
access="remote"
httpMethod="POST"
produces="application/json"
returntype="string">
<cfset local.testResponse= "Response">
<cfset local.testDebug= "Test Debug">
<cfif IsDefined("Form.UploadFile") AND Form.UploadFile NEQ "">
<cfsavecontent variable="local.debugInfo">
<cfdump var="#local.testDebug#">
</cfsavecontent>
<cffile action="write" file="c:\Coldfusion10\cfusion\wwwroot\backend\debugInfo.html" output="#local.debugInfo#">
</cfif>
<!--- GET THE FILE SENT WITH THE AJAX CALL AND DO SOMETHING --->
<!--- Here we should return some JSON that has a success value? --->
<cfreturn local.testResponse>
</cffunction>
</cfcomponent>
I think there is probably some concept i am missing here so im unsure of how to really word this question. Apologies...
Upvotes: 2
Views: 1780
Reputation: 4488
This was knowledge problem rather than any real technical difficulty. My file was getting sent properly, to 'pick up' a file on the Coldfusion end of the request I used this.
<cffile
action = "upload"
destination = "C:\ColdFusion10\cfusion\wwwroot\tempFiles\"
accept = "image/jpeg, application/xlsx"
nameConflict = "overwrite"
result="myFile"
>
Thanks to sunny for the pointers
Upvotes: 1