?
Solved

cffile action=delete

Posted on 2003-02-21
4
Medium Priority
?
268 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 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: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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

This is a guide to setting up a new WHM/cPanel Server to be used for web hosting accounts. It is intended for web hosting company administrators and dedicated server owners. For under $99 per month (considering normal rate of Big Data Cetnters like …
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

765 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