Go Back   CodingForums.com > :: Server side development > Other server side languages/ issues > ColdFusion

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 03-03-2009, 02:42 PM   PM User | #1
Rick7707
New to the CF scene

 
Join Date: Dec 2008
Location: Houston, TX
Posts: 7
Thanks: 2
Thanked 0 Times in 0 Posts
Rick7707 is an unknown quantity at this point
Multiple File Upload Help

I keep getting this error: Element NUMBEROFFIELDS is undefined in VARIABLES

If anyone could help I would appreciate it.

Here is the client side:
<cfset numberoffields = 4>
<form action="fileupload.cfm" method="post" enctype="multipart/form-data">
<cfloop index="i" from="1" to="#numberoffields#" step="1">
<cfset filename = "file" & #i#>

<input type="file" name="<cfoutput>#filename#</cfoutput>" /><br />

</cfloop>

<input type="submit" name="submit" value="Upload">
</form>

Here is the server side:
<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "form.file" & #i#>

<cfif evaluate(variables.filename) NEQ "">

<cffile action="upload" filefield="#variables.filename#" destination="d:\bla\bla\bla" accept="image/jpg, image/png, image/x-png, application/msword, application/vnd.ms-word, application/mspowerpoint, application/vnd.ms-powerpoint, application/pdf, application/msexcel, application/vnd.ms-excel" nameconflict="makeunique">
</cfif>
</cfloop>
Rick7707 is offline   Reply With Quote
Old 03-20-2009, 03:16 PM   PM User | #2
SunshineFreedom
New to the CF scene

 
Join Date: Mar 2009
Location: Texas
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
SunshineFreedom is an unknown quantity at this point
Quote:
Originally Posted by Rick7707 View Post
I keep getting this error: Element NUMBEROFFIELDS is undefined in VARIABLES
Your numberoffields variable is not persistent. One option is to set it as a hidden form field, then on your server-side read it as form.numberoffields.

Code:
...
Client side:
<form action="fileupload.cfm" method="post" enctype="multipart/form-data">
<input type="hidden" name="numberoffields" value="4">

	<cfloop index="i" from="1" to="#numberoffields#" step="1">
    <cfset filename = "file" & #i#>...
Server side:

Code:
<cfloop index="i" from="1" to="#form.numberoffields#" step="1">
SunshineFreedom is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 07:43 PM.


Advertisement
Log in to turn off these ads.