Skip to main content
chrisbowyer
Known Participant
June 26, 2010
Question

Variable Directory Issue Using cffileupload

  • June 26, 2010
  • 1 reply
  • 514 views

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

    This topic has been closed for replies.

    1 reply

    chrisbowyer
    Known Participant
    June 26, 2010

    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" />