lulu50
asked on
Update my file
Hi,
I am not sure what I'm doing wrong to prevent it from updating my files.
I just want to update my files.
I am doing something wrong but not sure what it is.
Thanks,
Lulu
I am not sure what I'm doing wrong to prevent it from updating my files.
I just want to update my files.
I am doing something wrong but not sure what it is.
Thanks,
Lulu
<!--- begin update Uploaded files --->
<cfsetting showdebugoutput="yes">
<cfset filelocation = expandpath('uploadedfiles/')>
<cfset maxFiles = 3>
<cfset Attachments="">
<cfloop from="1" to="#variables.maxFiles#" index="ii">
<cftry>
<cfset variables["Descp" & ii] = Form["FileDescription" & ii]>
<cfset variables["FileName" & ii] = Form["FileName" & ii]>
<cfset variables["FileID" & ii] = Form["FileID" & ii]>
<cfif StructKeyExists(form,"AttachFile" & ii) && len(trim(Form["AttachFile" & ii]))>
<CFFILE ACTION="UPLOAD"
FILEFIELD="AttachFile#ii#"
DESTINATION="#variables.filelocation#"
NAMECONFLICT="makeunique">
<cfset Attachments=ListAppend(variables.Attachments,cffile.serverfile)>
</cfif>
<cfcatch>
<br>#cfcatch.message#<br>#cfcatch.detail#<br>
#cfcatch.tagContext[1].template# Line #cfcatch.tagContext[1].line#
</cfcatch></cftry>
</cfloop>
<cfquery name = "QLogFiles" datasource="#strDSN#" username="#strUID#" password="#strPWD#" result="rs">
Set Nocount On;
<cfset cnt=0>
<cfloop list="#variables.Attachments#" index="ii">
<cfset cnt++/>
update Files
SET
<cfif #variables["Descp" & cnt]# neq ''>
FileName = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#variables["Descp" & cnt]#">,
<cfelse>
FileName = <cfqueryparam cfsqltype="CF_SQL_VARCHAR" value="#variables["FileName" & cnt]#">,
</cfif>
<cfif len(trim(variables.Attachments))>
<cfif FileExists(variables.filelocation & ii)>
<cfif IsDefined('ToBase64(variables.filelocation & ii)') && #ToBase64(variables.filelocation & ii)# neq ''>
UploadedFile = <cfqueryparam cfsqltype="cf_sql_longvarchar" value="#ToBase64(variables.filelocation & ii)#">,
</cfif>
<cfif IsDefined('ToBase64(variables.filelocation & ii)') && #ToBase64(variables.filelocation & ii)# neq ''>
uploadedasbinary = <cfqueryparam cfsqltype="cf_sql_blob" value="#FileReadBinary(variables.filelocation & ii)#">,
</cfif>
</cfif>
</cfif>
CreatedDate = <cfqueryparam cfsqltype="cf_sql_date" value="#Now()#">
WHERE FileID = #variables["FileID" & ii]#
</cfloop>
</cfquery>
<cfoutput>SQL: #rs.SQL#</cfoutput>
<!--- end of update file --->
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you.
I got it to work!!!!!!
I got it to work!!!!!!
1. Show the image or doc file on the screen.
2. upload another file and replace one.
3. delete existing files..
can you show your complete code here