1 Reply Latest reply on Nov 5, 2009 7:43 PM by Adam Cameron.

    Delete Select Files


      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.');"/> 





      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>
                  <cfloop list="#filestoremove#" index="item">
                      <cffile action="Delete" file="E:\WEB\bkllp\manage\users\#GetName.accountant#\#fileLoc#\#urlDecode(item)#">



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

        • 1. Re: Delete Select Files
          Adam Cameron. Level 5

          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.