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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

upalod multiple file

Status
Not open for further replies.

3443232

Technical User
Dec 18, 2003
6
US
<form method=&quot;post&quot; action=&quot;confirmation3.cfm&quot; enctype=&quot;multipart/form-data&quot; name=&quot;informacion&quot;>
<input type=&quot;file&quot; name=&quot;datafile&quot; id=&quot;datafile1&quot; required=&quot;yes&quot;>
<input type=&quot;file&quot; name=&quot;datafile&quot; id=&quot;datafile2&quot; required=&quot;no&quot;>
<input type=&quot;file&quot; name=&quot;datafile&quot; id=&quot;datafile3&quot; required=&quot;no&quot;>
<input type=&quot;file&quot; name=&quot;datafile&quot; id=&quot;datafile4&quot; required=&quot;no&quot;>
<input name=&quot;Enviar&quot; type=&quot;submit&quot; id=&quot;Enviar&quot; value=&quot;Enviar&quot;>
</form>

I am trying to upload multiple file using &quot;CFFile&quot;. Form above.
One of my input file is required (I could do this with simple javascript) the other are not requeired. However, if the visitor leave empty one of those input it will get a error. I want the user be able to leave the input blank.

Now I have this and it works but if the users leave input form blank he will get an error

<cfif isdefined(&quot;form.Enviar&quot;)>
<cffile action=&quot;upload&quot; filefield=&quot;datafile1&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
<cffile action=&quot;upload&quot; filefield=&quot;datafile2&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
<cffile action=&quot;upload&quot; filefield=&quot;datafile3&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
<cffile action=&quot;upload&quot; filefield=&quot;datafile4&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
Los archivos estan en nuestro datos! <br><br>
</cfif>

thank for your help
 
It looks like all of your form fields are named the same (datafile), that may be causing a problem. But what I really think is happening is that you're not checking for the existance of any of your form fields before trying to upload them. It's trying to upload EVERY field, and since some of them are blank, they don't exist and it throws an error.

Try:

<cfif isdefined(&quot;form.Enviar&quot;)>
<cfif IsDefined(&quot;Form.datafile1&quot;)>
<cffile action=&quot;upload&quot; filefield=&quot;datafile1&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
</cfif>
<cfif IsDefined(&quot;Form.datafile2&quot;)>
<cffile action=&quot;upload&quot; filefield=&quot;datafile2&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
</cfif>
<cfif IsDefined(&quot;Form.datafile3&quot;)>
<cffile action=&quot;upload&quot; filefield=&quot;datafile3&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
</cfif>
<cfif IsDefined(&quot;Form.datafile3&quot;)>
<cffile action=&quot;upload&quot; filefield=&quot;datafile4&quot; destination= &quot;D:\inetpub\ accept=&quot;image/jpg,image/gif&quot; nameconflict=&quot;makeunique&quot;>
</cfif>
Los archivos estan en nuestro datos! <br><br>
</cfif>


Hope This Helps!

Ecobb

&quot;Alright Brain, you don't like me, and I don't like you. But lets just do this, and I can get back to killing you with beer.&quot; - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top