Without looking at anything else, try this:
<cfif IsDefined("FORM.file_path_#count#") AND FORM["file_path_#count#"] NEQ
"">
....
....
....
<cffile action="UPLOAD" filefield="FORM['file_path_#count#']"...
Adrian
Building a database of ColdFusion errors at http://cferror.org/
-----Original Message-----
From: Nick Sweeney
Sent: 13 November 2008 16:49
To: cf-newbie
Subject: CFFile Batch Upload
I am trying to develop a multiple file upload form - but I am having an
issue with the CFFile - presumably because I am using variables incorrectly.
(Field names set by Form field cfloop) However I am having a brain poof and
can't see the issue - so I figured I would throw the error and question to
the group.
Thank you! - Nick
The ERROR:
The form field
"E:\CFusionMX\runtime\servers\default\SERVER-INF\temp\wwwroot-tmp\neotmp3534
9.tmp" did not contain a file.
The CODE:
<cfcase value="BatchUpload">
<cfset numberoffields = 10>
<!---
_______________________
See If File Was Added
_______________________
--->
<cfif IsDefined("FORM.BatchUpload") AND FORM.BatchUpload EQ "True">
<cfset message = "">
<cfloop index="count" from="1" to="#numberoffields#">
<cftry>
<!--- Set Variables --->
<cfset variables.MGID = Evaluate("form.MGID_#count#")>
<cfset variables.file_path = Evaluate("form.file_path_#count#")>
<cfset variables.Description = Evaluate("form.Description_#count#")>
<cfif isdefined("variables.file_path") AND
#variables.file_path# NEQ "">
<!---
CHANGE DIRECTORY TO THE SERVER'S DIRECTORY
Check that the directory exists to avoid getting a Coldfusion
error message.
--->
<cfset UniqFileDir = "#CreateUUID()#">
<cfset newDirectory =
"#APPLICATION.SiteRootDir#\Account\AccountFiles\#UniqFileDir#">
<cfset currentDirectory =
"#APPLICATION.SiteRootDir#\Account\AccountFiles\#UniqFileDir#">
<!--- Step One: Create Directory --->
<cfdirectory action = "create" directory = "#newDirectory#"
>
<!--- NOW save the file --->
<cffile
action="UPLOAD"
filefield="#variables.file_path#"
destination="#newDirectory#"
nameconflict="MAKEUNIQUE"
accept="application/pdf, application/msword,
application/x-stuffit, application/x-zip-compressed,
application/vnd.ms-excel, application/psd, application/ai, application/fhd,
application/cdr, application/dwg, model/vnd.dwf, application/dwf,
application/eps, text/richtext, application/x-shockwave-flash,
application/octet-stream, image/gif, image/jpeg, image/jpg, image/*,
text/html, text/txt, text/plain, application/vnd.ms-powerpoint, audio/mpeg,
video/x-ms-wmv">
<!---
NOW UPDATE THE DB FILE INFORMATION
--->
<cfquery datasource="#Application.DSN#"
username="#Application.username#" password="#Application.password#">
INSERT INTO Account_Files (FileName,
UniqDirectory, Description, PostedBy) VALUES (
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#CFFile.ServerFile#">
,
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#UniqFileDir#">
,
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#variables.Description#">
,
<cfqueryparam cfsqltype="cf_sql_varchar"
value="#FORM.PostedBy#">
)
</cfquery>
<!--- Step Two: Get new File ID --->
<cfquery name="qryGetNewFileID"
datasource="#Application.DSN#" username="#Application.username#"
password="#Application.password#" maxrows="1">
SELECT Account_Files.AFID
FROM Account_Files
ORDER BY AFID Desc
</cfquery>
<cfset NewFileID =
#qryGetNewFileID.AFID#>
<!--- Step Three: Insert Into File Links --->
<cfquery datasource="#Application.DSN#"
username="#Application.username#" password="#Application.password#">
INSERT INTO Account_FileLinks (AFID, MGID,
ESID) VALUES (
#NewFileID#
, <cfqueryparam cfsqltype="cf_sql_integer"
value="#variables.MGID#">
, 0
)
</cfquery>
<cfset message =
message & ",File #count# (#file.serverfile#) was
uploaded">
</cfif>
<cfcatch type="any">
Files Did Not Upload - <cfoutput>#count#<br />
#cfcatch.message# #cfcatch.detail# :: #Now()#</cfoutput><br /><br />
</cfcatch>
</cftry>
</cfloop>
<cfloop list="#message#" index="i">
<cfoutput>#i#</cfoutput><br />
</cfloop>
</cfif>
<h1>Batch Upload</h1>
<p class="instruction">Posting a file to a Mail Group allows ALL users in
that gourp to view the file.<br>
NOTE: "Description" is the text that the User sees to launch/open the
file.</p>
<cfquery name="qryGetEmailGroups" datasource="#Application.DSN#"
username="#Application.username#" password="#Application.password#">
SELECT *
FROM EmailGroup
ORDER BY MGTitle ASC
</cfquery>
<cfif IsDefined("FORM.BFDAdmin_AddFile") AND FORM.BFDAdmin_AddFile EQ
"AddFile" AND FORM.file_path NEQ "">
File <cfoutput>#CFFile.ClientFile#</cfoutput> Uploaded!
</cfif>
<p>
<form method="post" name="AddFile"
action="<cfoutput>#CurrentPage#?mode=BatchUpload</cfoutput>"
enctype="multipart/form-data" >
<table cellspacing="0" cellpadding="2" border="0">
<tr>
<th class="FA-cellborder2">Mail Group</th>
<th class="FA-cellborder2">Description</th>
<th class="FA-cellborder2">File</th>
</tr>
<cfloop index="count" from="1" to="#variables.numberoffields#" step="1">
<cfoutput>
<tr>
<td class="FA-cellborder1">
<select name="MGID_#count#">
<cfloop query="qryGetEmailGroups"><option
value="#qryGetEmailGroups.MGID#" <cfif #qryGetEmailGroups.MGID# EQ
#URL.MGID#>selected</cfif>>#qryGetEmailGroups.MGTitle#</option></cfloop>
</select>
</td>
<td class="FA-cellborder1"><input name="Description_#count#"
size="30" value=""></td>
<td class="FA-cellborder1"><input type="file"
name="file_path_#count#"></td>
</tr>
</cfoutput>
</cfloop>
</tr>
<td colspan="3"><div align="right">
<input type="submit" name="submit" value="Upload File"
onClick="btnChange( this )" class="SubButtonOff"
onmouseover="this.className='SubButtonOn'"
onmouseout="this.className='SubButtonOff'"/>
</div></td>
</tr>
</table>
<INPUT TYPE="hidden" name="MAX_FILE_SIZE" value="10000000000000000">
<input type="hidden" name="PostedBy"
value="<cfoutput>#Session.BFDAdmin_Username#</cfoutput>">
<input type="hidden" name="BatchUpload" value="True">
</form>
</p>
</cfcase>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to
date
Get the Free Trial
http://ad.doubleclick.net/clk;207172674;29440083;f
Archive:
http://www.houseoffusion.com/groups/cf-newbie/message.cfm/messageid:4150
Subscription: http://www.houseoffusion.com/groups/cf-newbie/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15