Ok I just finished this tutorial on "multiple file upload with cffile". The url
for the tutorial is here:
http://www.devarticles.com/c/a/ColdFusion/Multiple-File-Upload-with-CFFILE/2/
I did everything right. At the end of the tutorial the guy says this.
"When you do the insert statement, use #file.serverfile# as the filename and
not #form.filename#. ". So I did and I keep getting this error message:
Element SERVERFILE is undefined in FILE.
The error occurred in C:\CFusionMX7\wwwroot\elkcorp\admin\FileUpload.cfm: line
4
2 : INSERT INTO ElkLogos (ThumbImageName, LgImageName, EpsImageName,
Approved, LogoName, "Description", LgFileSize, LgFileType, EpsFileSize,
EpsFileType)
3 : VALUES (
4 : '#File.ServerFile#',
5 : '#File.ServerFile#',
6 : '#File.ServerFile#',
What is wrong with my code attatched?
<cfquery datasource="connCoop">
INSERT INTO ElkLogos (ThumbImageName, LgImageName, EpsImageName, Approved,
LogoName, "Description", LgFileSize, LgFileType, EpsFileSize, EpsFileType)
VALUES (
'#File.ServerFile#',
'#File.ServerFile#',
'#File.ServerFile#',
'#Form.approved#',
'#Form.LogoName#',
'#Form.Description#',
'#Form.LgFileSize#',
'#Form.LgFileType#',
'#Form.EpsFileSize#',
'#Form.EpsFileType#')
</cfquery>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="Elk_admin_styles.css" rel="stylesheet" type="text/css" />
<link href="../styles/styles.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.style1 {
color: #FF0000;
font-weight: bold;
}
.style2 {color: #FF0000}
-->
</style>
</head>
<body><table width="100%" border="0" align="center" cellpadding="0"
cellspacing="0" id="pagetitle">
<tr>
<td width="33%" align="center"><a href="coop_login_confirmation.cfm"
class="title">Admin Main</a></td>
<td width="33%" align="center"><span class="title">Admin Coop Upload Elk
Logos </span></td>
<td width="33%" align="center"><span class="title">Logout</span></td>
</tr>
<tr><td align="left" colspan="3"> </td></tr>
<tr><td align="left" colspan="3">Please understand that all fields are
required on this form and take note of the three logo fields that allow you to
upload files!</td></tr>
<tr><td align="left" colspan="3">Filenames cannot contain special text
characters or spaces in the filename.
Filenames must be under 20 characters.</td></tr>
<tr><td align="left" colspan="3">
<span class="style1">Please load your logos in this order.</span> <span
class="style2">Otherwise the gallery that the user sees will be
affected.</span></td>
</tr>
</table>
<!--- The Action Area --->
<cfset numberoffields = 3>
<cfif isdefined("form.upload")>
<cfset message = "">
<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "File.ServerFile" & #i#>
<cfif evaluate(variables.filename) neq "">
<cffile action="UPLOAD"
destination="C:\CFusionMX7\wwwroot\elkcorp\images\coop\logos\elk\"
nameconflict="MakeUnique"
filefield="#variables.filename#">
<cfset message = message &
",File%20#i#%20(#file.serverfile#)%20was%20uploaded">
<cfelse>
<cfset message = message & ",File%20#i#%20was%20empty">
</cfif>
</cfloop>
<cflocation url="FileUpload.cfm?msg=#variables.message#">
<cfelse>
<h2> </h2>
<cfif isdefined("url.msg")>
<div style="color:#FF0000;">
<cfloop list="#url.msg#" index="i">
<cfoutput>#i#</cfoutput><br />
</cfloop>
</div>
</cfif>
<!--- The Client Side Area --->
<form name="form1" enctype="multipart/form-data" method="POST">
<table width="525" border="0" align="left" cellpadding="0" cellspacing="0"
id="logosubmissions">
<tr>
<td valign="top" align="right"><strong>ThumbnailLogo:</strong><br />
<strong>Normal Logo:</strong><br />
<strong>Eps Logo:</strong><br /></td>
<td><cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "file" & #i#>
<input type="File" name="<cfoutput>#variables.filename#</cfoutput>"
/><br />
</cfloop> </td></tr>
<tr><td align="right"><strong>Select Your Normal Logo File Size:
</strong>(3kb)</td><td><input name="LgFileSize" type="text" id="LgFileSize"
size="10" maxlength="10" /></td></tr>
<tr>
<td align="right"><strong>Select Your Normal Logo File Type:
</strong></td>
<td><input name="LgFileType" type="text" id="LgFileType" value="jpg"
size="10" maxlength="10" /></td>
</tr>
<tr>
<td><div align="right"><strong>Select Your Eps Logo File Size:</strong>
(3kb) </div></td>
<td><input name="EpsFileSize" type="text" id="EpsFileSize" size="10"
maxlength="10" /></td>
</tr>
<tr>
<td><div align="right"><strong>Select Your Eps Logo File
Type:</strong></div></td>
<td><input name="EpsFileType" type="text" id="EpsFileType" value="eps"
size="10" maxlength="10" /></td>
</tr>
<tr>
<td><div align="right"><strong>Logo Name: </strong></div></td>
<td><input name="LogoName" type="text" id="LogoName" size="25"
maxlength="50" /></td>
</tr>
<tr>
<td><div align="right"><strong>Description: </strong></div></td>
<td><input name="Description" type="text" id="Description" size="25"
maxlength="50" /></td>
</tr>
<tr><td align="right"><label>
<input type="reset" name="Reset" value="Reset" />
</label></td><td>
<input type="Submit" name="upload" value="Upload">
<input name="approved" type="hidden" id="approved" value="0" /></td>
</tr>
</table>
</form>
</cfif>
</body>
</html>
Mountain Lover - 09 Aug 2006 05:47 GMT
file is deprecated for cffile
http://livedocs.macromedia.com/coldfusion/7/htmldocs/00000253.htm
HTH

Signature
Tim Carley
www.recfusion.com
info@NOSPAMINGrecfusion.com
bigbrain28 - 28 Sep 2006 19:23 GMT
Looks to me like you have the query trying to write the info about the file
before the file is uploaded. Is the code all one page? The upload THEN query to
insert the data would have to come after (on an action page the form submitted
to) for #file.serverFile# to be evaluated.
Abinidi - 29 Sep 2006 20:56 GMT
Your query needs to go in the action section of your code where you have the
CFFILE being looped over.
<cfloop index="i" from="1" to="#variables.numberoffields#" step="1">
<cfset filename = "File.ServerFile" & #i#>
<cfif evaluate(variables.filename) neq "">
<cffile action="UPLOAD"
destination="C:\CFusionMX7\wwwroot\elkcorp\images\coop\logos\elk\"
nameconflict="MakeUnique"
filefield="#variables.filename#">
<cfquery datasource="connCoop">
INSERT INTO ElkLogos (ThumbImageName, LgImageName, EpsImageName, Approved,
LogoName, "Description", LgFileSize, LgFileType, EpsFileSize, EpsFileType)
VALUES (
'#File.ServerFile#',
'#File.ServerFile#',
'#File.ServerFile#',
'#Form.approved#',
'#Form.LogoName#',
'#Form.Description#',
'#Form.LgFileSize#',
'#Form.LgFileType#',
'#Form.EpsFileSize#',
'#Form.EpsFileType#')
</cfquery>
<cfset message = message &
",File%20#i#%20(#file.serverfile#)%20was%20uploaded">
<cfelse>
<cfset message = message & ",File%20#i#%20was%20empty">
</cfif>
</cfloop>