I want to use a javascript's comfirm function to ask the user whether to overwrite the file during upload.
The code as follow
----------------------
<script language= "JavaScript">
if (confirm("The file already exists. Are you sure you want to overwrite it?") {
<cfscript>
session.overwrite = true;
</cfscript>
}
</script>
<cfif isdefined("session.overwrite" and session.overwrite eq true>
<cffile action="Upload" filefield="form.#fieldname#" destination="#GV_photo_path##StructFind(session.strFileDownload, InfoTypeID)#" nameconflict="OVERWRITE">
<cfset session.strFilename["#id#"]["Filename"] = "#File.ServerFile#">
<cfset StructDelete(session, "overwrite">
</cfif>
However, no mather the user click "OK" or "Cancel", the session.overwrite is true.
How can I avoid this problem?
The code as follow
----------------------
<script language= "JavaScript">
if (confirm("The file already exists. Are you sure you want to overwrite it?") {
<cfscript>
session.overwrite = true;
</cfscript>
}
</script>
<cfif isdefined("session.overwrite" and session.overwrite eq true>
<cffile action="Upload" filefield="form.#fieldname#" destination="#GV_photo_path##StructFind(session.strFileDownload, InfoTypeID)#" nameconflict="OVERWRITE">
<cfset session.strFilename["#id#"]["Filename"] = "#File.ServerFile#">
<cfset StructDelete(session, "overwrite">
</cfif>
However, no mather the user click "OK" or "Cancel", the session.overwrite is true.
How can I avoid this problem?