texbala
asked on
cffile action=delete
I have a form with name, email fields and a file field for resume collection - resume has to be emailed to an address.I am not able to delete the file that I uploaded seconds ago. Pls. help!! - It attaches the file along with the e-mail, but doesn't delete the file and goes to catch block.
===============
<cftry>
<cfif FORM.filename neq "">
<cffile
action="upload"
filefield="filename"
destination="C:\webroot_de velopment\ alumni_cen ter\resume \"
nameconflict="Makeunique"
accept="application/msword , application/pdf, text/plain">
<cfset NewFile = "C:\webroot_development\al umni_cente r\resume\# file.serve rfile#">
</cfif>
<cfmail to="mail@email.com"
from="mail@email.com"
subject="subject"
>
Name =#name#
E-mail = #email#
<cfif IsDefined ("NewFile")>
<cfmailparam file="#NewFile#">
</cfif>
</cfmail>
<cfif IsDefined ("NewFile")>
<cfif FileExists("#NewFile#")>
<cffile action="delete" file="C:\resume\#NewFile#" >
<cfelse>
THE FILE DID NOT EXISTS
</cfif>
</cfif>
<!---
<cfif IsDefined ("NewFile")>
<cffile action="delete" file="C:\resume\">
</cfif> --->
<cfset blnIsSuccess = "TRUE">
<cfcatch type="any">
<cfset blnIsSuccess = "FALSE">
</cfcatch>
</cftry>
<cfif blnIsSuccess>
Email Sent
<cfelse>
Please upload a valid file. Valid file includes: Word document, PDF or text file<br>Please try again.
</cfif>
===============
===============
<cftry>
<cfif FORM.filename neq "">
<cffile
action="upload"
filefield="filename"
destination="C:\webroot_de
nameconflict="Makeunique"
accept="application/msword
<cfset NewFile = "C:\webroot_development\al
</cfif>
<cfmail to="mail@email.com"
from="mail@email.com"
subject="subject"
>
Name =#name#
E-mail = #email#
<cfif IsDefined ("NewFile")>
<cfmailparam file="#NewFile#">
</cfif>
</cfmail>
<cfif IsDefined ("NewFile")>
<cfif FileExists("#NewFile#")>
<cffile action="delete" file="C:\resume\#NewFile#"
<cfelse>
THE FILE DID NOT EXISTS
</cfif>
</cfif>
<!---
<cfif IsDefined ("NewFile")>
<cffile action="delete" file="C:\resume\">
</cfif> --->
<cfset blnIsSuccess = "TRUE">
<cfcatch type="any">
<cfset blnIsSuccess = "FALSE">
</cfcatch>
</cftry>
<cfif blnIsSuccess>
Email Sent
<cfelse>
Please upload a valid file. Valid file includes: Word document, PDF or text file<br>Please try again.
</cfif>
===============
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.
I will leave the following recommendation in the Cleanup topic area:
Split anandkp & cfarleyaz
Please leave any comments here within the next four days.
mrichmon
EE Cleanup Volunteer