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

session variables

Explorer ,
Feb 02, 2010 Feb 02, 2010

Hi,

I am trying to add the names of my uploads, but it keeps replacing the first item rather than adding more to the array.

<cfif IsDefined ("FORM.docs")>

      <cffile action="upload" nameconflict="overwrite"  destination="#ExpandPath("../../uploads/news")#" filefield="FORM.uploadDocuments" />
     <cfset SESSION.uploads = ArrayNew(1)>;
     <cfset ArrayAppend(SESSION.uploads, #CFFILE.clientfile#)>
     <cfdump var="#SESSION.uploads#">

</cfif>

Thanks,

Ross

521
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
Contributor ,
Feb 02, 2010 Feb 02, 2010

Please try this

<cfapplication sessionmanagement="true" >

<cfif IsDefined ("FORM.docs")>

      <cffile action="upload" nameconflict="overwrite"  destination="#ExpandPath("../../uploads/news")#" filefield="FORM.uploadDocuments" />


     <cfif NOT isdefined("SESSION.uploads")>
        <cfset SESSION.uploads = ArrayNew(1)>     
    </cfif>


     <cfset ArrayAppend(SESSION.uploads, #CFFILE.clientfile#)>
     <cfdump var="#SESSION.uploads#">

</cfif>

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
Engaged ,
Feb 02, 2010 Feb 02, 2010

You are not outputing the code where you loop over the form items.  All we see here is a new array made, then one item added.

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 Expert ,
Feb 03, 2010 Feb 03, 2010
LATEST

You can go one of 2 ways. Use Catchme_dileep's cfif, or else replace the line <cfset SESSION.uploads = ArrayNew(1)> with:

<cfparam name="SESSION.uploads" default="#ArrayNew(1)#">

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