3 Replies Latest reply on Sep 29, 2006 12:56 PM by Abinidi

    Using cffile multiple uploads..HELP!!

    jimmylharrell Level 1
      Ok I just finished this tutorial on "multiple file upload with cffile". The url for the tutorial is here: http://www.devarticles.com/c/a/ColdFusion/Multiple-File-Upload-with-CFFILE/2/

      I did everything right. At the end of the tutorial the guy says this.
      "When you do the insert statement, use #file.serverfile# as the filename and not #form.filename#. ". So I did and I keep getting this error message:

      Element SERVERFILE is undefined in FILE.
      The error occurred in C:\CFusionMX7\wwwroot\elkcorp\admin\FileUpload.cfm: line 4

      2 : INSERT INTO ElkLogos (ThumbImageName, LgImageName, EpsImageName, Approved, LogoName, "Description", LgFileSize, LgFileType, EpsFileSize, EpsFileType)
      3 : VALUES (
      4 : '#File.ServerFile#',
      5 : '#File.ServerFile#',
      6 : '#File.ServerFile#',

      What is wrong with my code attatched?

        • 1. Re: Using cffile multiple uploads..HELP!!
          Level 7
          file is deprecated for cffile
          http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000253.htm

          HTH
          --
          Tim Carley
          www.recfusion.com
          info@NOSPAMINGrecfusion.com
          • 2. Re: Using cffile multiple uploads..HELP!!
            bigbrain28 Level 1
            Looks to me like you have the query trying to write the info about the file before the file is uploaded. Is the code all one page? The upload THEN query to insert the data would have to come after (on an action page the form submitted to) for #file.serverFile# to be evaluated.
            • 3. Re: Using cffile multiple uploads..HELP!!
              Abinidi Level 1
              Your query needs to go in the action section of your code where you have the CFFILE being looped over.

              <cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
              <cfset filename = "File.ServerFile" & #i#>
              <cfif evaluate(variables.filename) neq "">
              <cffile action="UPLOAD"
              destination="C:\CFusionMX7\wwwroot\elkcorp\images\coop\logos\elk\"
              nameconflict="MakeUnique"
              filefield="#variables.filename#">
              <cfquery datasource="connCoop">
              INSERT INTO ElkLogos (ThumbImageName, LgImageName, EpsImageName, Approved, LogoName, "Description", LgFileSize, LgFileType, EpsFileSize, EpsFileType)
              VALUES (
              '#File.ServerFile#',
              '#File.ServerFile#',
              '#File.ServerFile#',
              '#Form.approved#',
              '#Form.LogoName#',
              '#Form.Description#',
              '#Form.LgFileSize#',
              '#Form.LgFileType#',
              '#Form.EpsFileSize#',
              '#Form.EpsFileType#')
              </cfquery>
              <cfset message = message & ",File%20#i#%20(#file.serverfile#)%20was%20uploaded">
              <cfelse>
              <cfset message = message & ",File%20#i#%20was%20empty">
              </cfif>
              </cfloop>