Skip to main content
Known Participant
February 2, 2010
Question

session variables

  • February 2, 2010
  • 3 replies
  • 574 views

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

    This topic has been closed for replies.

    3 replies

    BKBK
    Community Expert
    Community Expert
    February 3, 2010

    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)#">

    Participating Frequently
    February 2, 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.

    Dileep_NR
    Inspiring
    February 2, 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>