2 Replies Latest reply on Aug 7, 2006 1:27 PM by kaasu

    Multiple File Upload and Looping - Help

    Level 7
      I am trying to create a multiple file uploading page that uses looping to
      upload and also create the fields.

      For the fields I have:

      <cfif IsDefined('submit_number')>
      <cfset numproofs = #FORM.proofs#>
      <td class="maintext"><form action="" method="post"
      enctype="multipart/form-data" name="uploadfiles" id="uploadfiles">
      <table width="98%" border="0">
      <tr>
      <td colspan="2"><cfloop index="i" from="1"
      to="#FORM.proofs#"><table width="100%" border="0"><cfoutput>
      <tr>
      <td width="12%" class="maintext_bold"><div
      align="right">Proof File #i#: </div></td>
      <td width="88%"><input name="file#i#" type="file"
      class="maintext" /></td>
      </tr>
      <cfif project.projtype EQ 'image'><tr>
      <td class="maintext_bold"><div align="right">Add Border?
      </div></td>
      <td class="maintext"><input name="border#i#" type="radio"
      value="1" />
      Yes
      <input name="border#i#" type="radio" value="0"
      checked="checked" />
      No <span class="maintext_red_info">(Adds 1 pixel black
      border around your image file)</span></td>
      </tr>
      <cfelse>
      <input name="border#i#" type="hidden" id="border#i#" value="0" />
      </cfif>
      <tr>
      <td class="maintext_bold"> </td>
      <td> </td>
      </tr>
      </cfoutput>
      </cfloop></table>
      <tr>
      <td width="17%"><input name="project_id" type="hidden"
      id="project_id" value="#project.project_id#" />
      <cfoutput><input name="proofnumber" type="hidden" id="proofnumber"
      value="#numproofs#" /></cfoutput></td>
      <td width="83%"><input name="Submit" type="submit"
      class="maintext" value="Upload files" /></td>
      </tr>
      </table></cfif>

      That seems to work fine based on the selection of how many first.

      For the actual uploading I have:

      <cfif IsDefined ('Submit')>
      <cfloop index = "i" from="1" to ="#FORM.proofnumber#">
      <cfif IsDefined("form.file#i#")>
      <cfif evaluate("form.file#i#") NEQ "">
      <cfif project.projtype EQ 'Image'>
      <cffile accept="image/gif, image/jpeg, image/jpg, image/png, image/psd"
      action="upload"
      destination="E:\webs\softproofs.com\wwwroot\projects\prooffiles"
      filefield="file#i#" nameconflict="makeunique">
      <cfelseif project.projtype EQ 'Audio'>
      <cffile accept="audio/mpeg, audio/x-wav" action="upload"
      destination="E:\webs\softproofs.com\wwwroot\projects\prooffiles"
      filefield="file#i#" nameconflict="makeunique">
      <cfelseif project.projtype EQ 'Video'>
      <cffile accept="video/mpeg, video/x-msvideo, video/quicktime"
      action="upload"
      destination="E:\webs\softproofs.com\wwwroot\projects\prooffiles"
      filefield="file#i#" nameconflict="makeunique">
      <cfelseif project.projtype EQ 'Flash'>
      <cffile accept="application/x-shockwave-flash" action="upload"
      destination="E:\webs\softproofs.com\wwwroot\projects\prooffiles"
      filefield="file#i#" nameconflict="makeunique">
      </cfif>
      <cfquery name="uploadproofs" datasource="#Request.MainDSN#">
      INSERT INTO proof (file, size, project_id, owner, dirname, border)
      VALUES ('#File.ServerFile#', '#File.FileSize#', '#Form.project_id#',
      '#Session.MM_Username#', '#Session.MM_Username#', #FORM.border#i##)
      </cfquery>
      </cfif>
      </cfif>
      </cfloop>
      </cfif>

      I get an error telling me that the FORM.border is undefined. Why?

      I tried to create a hidden field with a value of 0 if the border field is
      not included on the page (audio, video, flash) to negate this. I used to put
      a cfif statement in my SQL statement to say if there was no border#i# then
      dont include it.

      Thanks

      --
      Wally Kolcz
      Developer / Support