Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

can I upload 3 files at once? 1

Status
Not open for further replies.

PTmon

IS-IT--Management
Mar 8, 2001
284
US
Basically I need to have a description with the possibility of having a PDF, a MP3 and a VIDEO, with icons that show up if the file is available. Trying to create the ability to add a new description, and then add whichever files will be associated with that description.
Thanks,
Paul

 
Sort of.

The simplest way would be to have three separate file fields... one marked "PDF", one marked "AUDIO", and one marked "VIDEO". The user selects files for each, or none, and submits the form.

Another way is to have a form that is something like:
Code:
<!--- create a unique ID for this form instance, if it doesn't already exist --->
<CFPARAM name=&quot;FORM.desc_id&quot; default=&quot;#CreateUUID()#&quot;>
<form ... method=&quot;POST&quot;>
   <input type=&quot;text&quot; name=&quot;description&quot; ...>
              :

   <!--- pass the unique ID in a hidden field --->
   <CFOUTPUT><input type=&quot;hidden&quot; name=&quot;desc_id&quot; value=&quot;#FORM.desc_id#&quot;></CFOUTPUT>
   <input type=&quot;file&quot; name=&quot;myFile&quot; ...>
   <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Add File&quot;>
              :

   <input type=&quot;submit&quot; name=&quot;submit&quot; value=&quot;Submit Description&quot;>
</form>

Then the trick is to descern which submit button was clicked. If it's the &quot;Add File&quot; button (ie -
Code:
<CFIF IsDefined(&quot;FORM.submit&quot;) AND CompareNoCase(FORM.submit,&quot;Add File&quot;) EQ 0>
), then you rename the files that were uploaded in the temp directory (&quot;CFFILE.serverfile&quot;) to a filename like
Code:
#FORM.desc_id#.#CFFILE.clientFileExt#
(this prevents the user from uploading more than one file of a given type... or, if that's not important, you can copy the file to a directory named &quot;
Code:
/#FORM.desc_id#
&quot;).

If the &quot;Submit Description&quot; button was clicked, simply take all the files that are named &quot;
Code:
#FORM.desc_id#.*
(or everything in the &quot;
Code:
/#FORM.desc_id#
&quot; directory, if that's the way you did it) and copy them to their proper place (wherever your descriptions are accessed within your webroot, or whatever).


Definitely the first way is easier ;-)


-Carl
 
Great Carl, thanks. I wasn't sure if you could have 3 seperate file fields in the same form or not. I guess as long as they are named something different I'm good to go. There will always be at least ONE type of file, so I'll just do if statements on my processing page to check for the files and process them.
Thanks again for taking the time.
PT



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top