?
Solved

cffile action=delete

Posted on 2003-02-21
4
Medium Priority
?
270 Views
Last Modified: 2013-12-24
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>

===============
0
Comment
Question by:texbala
3 Comments
 
LVL 17

Accepted Solution

by:
anandkp earned 200 total points
ID: 7997551
its going to the catch block cos ;

1. may be the path is not correct
2. may be the file dosent exists there

so perfrm a fileexists('#filepath#/#filename#')
if it does - the perform delete

that shld be it

let me know

K'Rgds
Anand
0
 

Assisted Solution

by:cfarleyaz
cfarleyaz earned 200 total points
ID: 8013245
In the code where you perform the delete:

<cfif IsDefined ("NewFile")>
 <cfif FileExists("#NewFile#")>
   <cffile action="delete" file="C:\resume\#NewFile#">
 <cfelse>
   THE FILE DID NOT EXISTS
 </cfif>
</cfif>


you are already storing the full path in the variable 'NewFile'.  So instead of:

<cffile action="delete" file="C:\resume\#NewFile#">

you just want to do this:

<cffile action="delete" file="#NewFile#">



0
 
LVL 35

Expert Comment

by:mrichmon
ID: 10931106
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
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Whether you have a site with just static html pages or a dynamic database-driven one, this step-by-step migration guide will help you get started with your new DV server. This guide is by no means comprehensive but it should cover the basics to get …
The following information will get you familiar with your new DV server, including the (mt) Account Center, the Plesk Control Panel, our world-renowned support department and the rest of the (mt) tools that come with your new service.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Is your organization moving toward a cloud and mobile-first environment? In this transition, your IT department will encounter many challenges, such as navigating how to: Deploy new applications and services to a growing team Accommodate employee…
Suggested Courses

621 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question