Link to home
Start Free TrialLog in
Avatar of texbala
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_development\alumni_center\resume\"
               nameconflict="Makeunique"
               accept="application/msword, application/pdf, text/plain">
       <cfset NewFile = "C:\webroot_development\alumni_center\resume\#file.serverfile#">
</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
Avatar of anandkp
anandkp
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mrichmon
mrichmon

No comment has been added lately, so it's time to clean up this question.
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