> I have been around the block with this error and at the moment am very
> frustrated.
John, I use the following snippets of code and have no problems with an
upload (esp note section 2)
section 1 (upload file form)
==================
<cfif ATTRIBUTES.FileAction EQ "addfile">
<cfform name="AddProductAttachment"
action="index.cfm?FuseAction=dbAddEditProductAttachment" method="post"
enablecab="Yes" enctype="multipart/form-data">
<cfoutput>
<input type="hidden" name="Product_ID" value="#ATTRIBUTES.Product_ID#">
<tr>
<th>New File:</th>
<td><INPUT type="file" name="ProductAttachment" size="25"
maxlength="250"></td>
</tr>
<tr>
<td></td>
<td><input type="submit" value="upload this new file"><input
type="button" value="cancel"
onClick="index.cfm?FuseAction=AddEditProduct&Product_ID=#ATTRIBUTES.Product_
ID#"></td>
</tr>
</cfoutput>
</cfform>
</cfif>
section 2 (process upload)
==================
<cfparam name="ATTRIBUTES.Product_ID" default="0" TYPE="Numeric">
<cfif ATTRIBUTES.Product_ID>
<!--- check that there is an attachment to
--->
<CFIF LEN(TRIM(ProductAttachment))>
<CFSET NameOfFile = "file still uploading">
<CFSET TypeOfFile = "unknown">
<cfset LocalFileName = "file still uploading">
<cftransaction>
<!--- get the maximum key from ProductAttachments
--->
<CF_ACT_MAX_ID datasource="#APPLICATION.dsn#"
tablename="ProductAttachments" primarykey="ProductAttachment_ID">
<!--- Insert the record into the
--->
<CFQUERY datasource="#APPLICATION.dsn#" name="addProductAttachments">
INSERT INTO ProductAttachments (
ProductAttachment_ID,
PA_ProductID,
PA_Name,
PA_Type,
PA_LocalName,
Active_YN,
CreatorID,
CreatedDate
)
VALUES
#MAX_ID#,
#ATTRIBUTES.Product_ID#,
'#NameOfFile#',
'#TypeOfFile#',
'#LocalFileName#',
1,
#SESSION.User.ID#,
#APPLICATION.now#
)
</CFQUERY>
<!--- Upload the file to the Attachments
ents) --->
<CFFILE action="UPLOAD" filefield="ProductAttachment"
destination="#APPLICATION.AttachmentsRootDir#\Products\#ATTRIBUTES.Product_I
D#\#Max_id#.xxx" nameconflict="OVERWRITE">
<CFSET NameOfFile = #file.ClientFile#>
<CFSET TypeOfFile = reverse(GetToken(reverse(NameOfFile),1,"."))>
<cfset LocalFileName = "P#ATTRIBUTES.Product_ID#_A#max_id#_#NameOfFile#">
<CFFILE action="RENAME"
source="#APPLICATION.AttachmentsRootDir#\Products\#ATTRIBUTES.Product_ID#\#M
ax_id#.xxx"
destination="#APPLICATION.AttachmentsRootDir#\Products\#ATTRIBUTES.Product_I
D#\#LocalFileName#">
<!--- Update the database with the real file
--->
<CFQUERY datasource="#APPLICATION.dsn#" name="updateProductAttachments">
Update ProductAttachments
SET
PA_Name='#NameOfFile#',
PA_type='#TypeOfFile#',
PA_LocalName='#LocalFileName#'
WHERE
ProductAttachment_ID=#Max_id#
</CFQUERY>
</cftransaction>
</CFIF>
</cfif>
------------------------------------------------------------------------------
Archives: http://www.eGroups.com/list/cf-talk
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.