Skip to main content
March 12, 2009
Question

Multiple File Upload and nameconflict=makeunique

  • March 12, 2009
  • 1 reply
  • 418 views
I have a form with two file upload fields. I like to use the makeunique value for the nameconflict attribute in my cffile tag. To record the correct filename to the database I use #file.ServerFile#. However when I have two files, the first file is referenced by #file.ServerFile#. I expected a dump of #file# to show an array with both file1 and file2 in it, but this isn't the case. How do I find file2's information?
    This topic has been closed for replies.

    1 reply

    Inspiring
    March 12, 2009
    > To record the correct filename to the database I use #file.ServerFile#

    #File# is deprecated. You should use #CFFILE# or the "result" attribute

    > I expected a dump of #file# to show an array with both file1 and file2 in it

    No, the resulting structure contains the results of the most recent upload only. Per the documentation "If two cffile tags execute, the results of the second overwrite the first.... So you must record the information for each upload before calling <cffile action="upload" ...> again. Alternatively, you could save the results to an array manually using the duplicate(..) function:

    <cfset yourArray = []>
    <cffile action="upload" ....>
    <cfset arrayAppend(yourArray, duplicate(CFFILE)>
    ...
    <cffile action="upload" ....>
    <cfset arrayAppend(yourArray, duplicate(CFFILE)>
    ... etcetera ...


    http://livedocs.adobe.com/coldfusion/7/htmldocs/00000253.htm#3540091