Copy link to clipboard
Copied
Can anyone help with how to set a variable directory in cffile when using cffileupload? Here's my simplified code:
<!--- APPLICATION.CFM --->
<cfapplication
name="test"
sessionmanagement="yes"
sessiontimeout="#CreateTimeSpan(0, 0, 20, 0)#">
<!--- UPLOAD.CFM --->
<!--- Simulate Session.clientId as if client has logged in by setting it here --->
<cfset Session.clientId = "1" />
<cffileupload url="upload_action.cfm" />
<!--- UPLOAD_ACTION.CFM --->
<!--- this works --->
<cffile
action="uploadAll"
destination="#ExpandPath('./upload/1')#"
nameconflict="makeunique" />
<!--- this does not work --->
<cffile
action="uploadAll"
destination="#ExpandPath('./upload/#Session.clientId#')#"
nameconflict="makeunique" />
<!--- Note. Directory structure ./upload/1 exists --->
Copy link to clipboard
Copied
It's OK now. Sorted it out myself. Needed to use a URL variable:
<!--- UPLOAD.CFM --->
<cffileupload url="upload_action.cfm?id=#Session.clientId#" />
<!--- UPLOAD_ACTION.CFM --->
<cffile
action="uploadAll"
destination="#ExpandPath('./upload/#Url.id#')#"
nameconflict="makeunique" />