Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Variable Directory Issue Using cffileupload

Community Beginner ,
Jun 25, 2010 Jun 25, 2010

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

487
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jun 26, 2010 Jun 26, 2010
LATEST

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources