在Coldfusion CFC中接收上传的文件 [英] Receiving an uploaded file in a Coldfusion CFC

查看:111
本文介绍了在Coldfusion CFC中接收上传的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Backbone前端,它将上传的文件发送restful电话到Coldfusion后端。



我需要知道如何文件一旦它达到我的CFC。不幸的是我有一些疑问,是否该文件是发送,我的POST发生了很好,并返回一个基本的字符串从CFC,所以我知道是工作。



POST负载看起来像这样

  ----- -WebKitFormBoundarymjCH1xJJ2D10ncj8 
Content-Disposition:form-data; name =qqfile filename =Jellyfish.jpg
Content-Type:image / jpeg


------ WebKitFormBoundarymjCH1xJJ2D10ncj8--



我使用jquery FineUploader发送请求。



我目前正在使用并在CFC端拾取文件。

 < cfcomponent displayname =import
rest =true
restPath =/ import>

< cffunction name =import
access =remote
httpMethod =POST
produce =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 =writefile =c:\Coldfusion10\cfusion\wwwroot\backend\debugInfo.htmloutput =#local.debugInfo#>
< / cfif>

<!--- GET THE FILE SENT WITH THE AJAX CALL AND DO SOMETHING --->

<!---这里我们应该返回一个有成功值的JSON? --->
< cfreturn local.testResponse>

< / cffunction>


< / cfcomponent>

我认为可能有一些概念我在这里丢失,所以我不确定如何真正写这个问题。抱歉...

解决方案

这是知识问题,而不是任何真正的技术难题。我的文件被正确发送,以便在Coldfusion结束时使用此文件来拾取一个文件。

 < ; cffile 
action =upload
destination =C:\ColdFusion10\cfusion\wwwroot\tempFiles\
accept =image / jpeg,application / xlsx
nameConflict =overwrite
result =myFile
>

由于指针太阳,


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...

解决方案

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

这篇关于在Coldfusion CFC中接收上传的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆