Link to home
Start Free TrialLog in
Avatar of dthomas06
dthomas06

asked on

Deleting a file from the coldfusion server

How do I delete a file directly after it has been selected for download?  Everything I keep doing ends up deleting the entire directory or just a specific file.  

I'm sorry if this is a stupid question.
Avatar of SidFishes
SidFishes
Flag of Canada image

can you post a code snip?
Avatar of dthomas06
dthomas06

ASKER

<cfloop query="getfile">
   <cfif Type IS "Dir">
     <a href="#cgi.SCRIPT_NAME#?DirPath=#url.DirPath#\#name#&CaseN=#url.CaseN#"><img src="../images/folder.gif" width="19" height="17" border="0"> #name#</a>
     <cfelse>
    #name#<a href="NewIndex3_VOpenFile.cfm?filepath=#url.DirPath#%5C#name#" target="_blank"> Download</a> <cffile action="delete" file="#url.DirPath#%5C#name#">
</cfif>         
  <br>
</cfloop>
it is not a stupid question, just a very unclear one:
- what do you mean by "after is has been selected for download"? when exactly is this moment? where in your application logic does this happen?
- post the code you are currently using to delete the file, and it will be easier for everyone to see where the problem may be.

"Everything I keep doing ends up deleting the entire directory..." - not good
"... or just a specific file." - sn;t this what you want, to delete a specific file?
Sorry it's not clear.  

After the people log in to the system and click to see what files are available for download a list is pulled of Files located on a section of our directory.  As soon as they click download on a specific file or several minutes after the fact they want the file to be deleted from the directory.  

As far as the specific file being deleted the only way that happens is when I plug in the files name in the tag <cffile action="delete" file="#url.DirPath#%5C#name#">.  

ASKER CERTIFIED SOLUTION
Avatar of azadisaryev
azadisaryev
Flag of Hong Kong 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
Thank you so much azadisaryev.  I just did it and it worked.  I was concerned about a file downloading quick enough and said numerous times that we needed to make sure the file would complete downloading as we are looking at files over 40 MB.