我知道有人问过这个问题,但我似乎找不到有效的解决方案。
我有一个 CFM 页面,它使用以下内容将数据传递给 CFC
<cfinvoke
component="common.cfcs.geotrails"
method="UpdateGeoTrail">
<cfinvokeargument name="title" value="#form.title#"/>
<cfinvokeargument name="Description_short" value="#form.Description_short#"/>
<cfinvokeargument name="Description" value="#form.description#"/>
<cfinvokeargument name="GTID" value="#form.gtid#"/>
<cfinvokeargument name="CatID" value="#form.catid#"/>
<cfif structKeyExists(form,"fileUpload") and len(form.fileUpload)>
<cfinvokeargument name="fileUpload" value="#form.fileUpload#"/>
</cfif>
</cfinvoke>
在接收数据的 CFC 中,我按照Adobe Cookbook中的指示进行操作
<cffunction name="UpdateGeoTrail" access="public" returntype="void">
<cfargument name="title" type="string" required="yes">
<cfargument name="Description_short" type="string" required="yes">
<cfargument name="Description" type="string" required="yes">
<cfargument name="GTID" type="numeric" required="yes">
<cfargument name="CatID" type="numeric" required="yes">
<cfargument name="fileUpload" type="string" required="no">
<!--- IF THE IMAGE HAS BEEN UPLOADED --->
<!--- set the full path to the images folder --->
<cfif isdefined("arguments.fileUpload") AND len(arguments.fileUpload)>
<cfset tempmediapath = "#expandPath('/')#media/gtimages/temp/">
<cfset mediapath = "#expandPath('/')#media/gtimages/">
<cfset var cffile = "">
<cffile action="upload"
filefield="#ARGUMENTS.fileUpload#"
destination="#TempMediaPath#"
nameconflict="makeunique">
...
但我仍然收到可怕的错误信息......
“表单字段 /data/disk01/opt/coldfusion9/runtime/servers/coldfusion/SERVER-INF/temp/wwwroot-tmp/neotmp5003883285207133802.tmp 不包含文件。”
如果我按照 StackExchange 的说明进行操作(CFFILE - 使用组件上传文件)
<cffile action="upload"
filefield="fileUpload"
destination="#TempMediaPath#"
nameconflict="makeunique">
它通过没有错误,但<CFDUMP>
显示:[空字符串]。
我错过了什么。
谢谢。
菲尔