0 Replies Latest reply on Aug 6, 2006 8:39 AM by Newsgroup_User

    Multiple uploads - Setting up the fields.

    Level 7
      I would like to make a page where the members can upload up to 4 images for
      their clients design proofs. Searching through examples and posts, I came up
      with this code to upload and insert the information into the database:

      <cfif IsDefined ('Submit')>
      <cfloop index = "i" from =1 to =4>
      <cfif IsDefined("form.file#i#")>
      <cfif evaluate("form.file#i#") NEQ "">
      <cffile accept="image/gif, image/jpeg, image/jpg, image/png, image/psd"
      action="upload"
      destination="E:\webs\softproofs.com\wwwroot\projects\prooffiles"
      filefield="ImageName#i#" nameconflict="makeunique">
      <cfquery name="uploadproofs" datasource="#Request.MainDSN#">
      INSERT INTO proof (file, size, project_id, owner, dirname <cfif FORM.border
      GT "">,border</cfif>)
      VALUES ('#File.ServerFile#', '#File.FileSize#', '#Form.project_id#',
      '#Session.MM_Username#', '#Session.MM_Username#' <cfif FORM.border#i# GT
      "">, #FORM.border#i##</cfif>)
      </cfquery>
      </cfif>
      </cfif>
      </cfloop>
      </cfif>

      What I would like to know is:

      1.) Did I write the code above correctly to loop through the fields and
      upload each
      2.) Is it better to set each of the file fields manually (file1, file2,
      file3, file4) or to set 1 field and have it loop 4 times using the i to name
      the fields?
      3.) Do I have to also set the 'border' form element to #i# to make them
      unique during the loop. I have them set as border1, border2, border3,
      border4 currently. They are radio buttons and have one selected
      automatically so there is no need to evaluate them.

      --
      Wally Kolcz
      Developer / Support