Skip to main content
Inspiring
November 5, 2009
Question

Delete Select Files

  • November 5, 2009
  • 1 reply
  • 459 views

I need to delete files based on a checkbox selection. It looks at though the code works but it doesn't actually delete the file. Not sure where I've gone wrong. Any help with this would be great. Thanks.

Here is the first page, user_delete.cfm contains this code:

<form action="delete_submit.cfm" method="post" enctype="multipart/form-data" name="importform" id="importform">

     <input type="checkbox" name="filelist" value="#URLEncodedFormat(dir.name)#" class="formfield"/>#dir.name#

     <input type="submit" name="Delete" class="formbutton" value="Delete Checked" onclick="return confirm('Are you sure you want to delete the checked errors? This action cannot be reversed.');"/> 

</form>

Here is the delete_submit.cfm page:

            <cfparam name="attributes.Delete" default="">
            <cfparam name="filestoremove" default="">
           
            <cfif attributes.Delete IS "Delete Checked" AND isDefined("attributes.filelist")>
                <cfset filestoremove = attributes.filelist>
            </cfif>
                       
            <cfloop list="#filestoremove#" index="item">
                <cffile action="Delete" file="E:\WEB\bkllp\manage\users\#GetName.accountant#\#fileLoc#\#urlDecode(item)#">
            </cfloop>         

I know that #GetName.accountant# and the #fileLoc# are correct...

This topic has been closed for replies.

1 reply

Inspiring
November 6, 2009

Is the <cfloop> code definitely running?

<cffile> is good in that if anything at all happens that it doesn't like, it'll throw an exception quick smart.

So if the functionality is not working and you'renot getting an error... I reckon the <cffile> ain't actually being called.

--

Adam