Skip to main content
Known Participant
December 15, 2008
Question

deleting a folder

  • December 15, 2008
  • 2 replies
  • 388 views
Hi,

My site is sorted into two main folders 'frontend' and 'backend'

In the backend I am trying to delete my gallery with the file

backend > gallery > deleteGallery.cfm

The gallery folder is in the frontend and contains images called image1.jpg, image2.jpg etc.

frontend > gallery > galleryImages > gallery1

how can I delete this folder and all the images in it? Do I use expand path?

I keep getting a folder does not exist error.

Thanks,

R.
    This topic has been closed for replies.

    2 replies

    HulfyAuthor
    Known Participant
    December 15, 2008
    I can delete the folder now but...

    It seems I cannot delete it when there are any files in it but when it is empty it can be deleted. Is this normal or can I set the permissions when I upload them?
    Inspiring
    December 15, 2008
    Hi,

    While using <cfdirectory> you will be getting a query object with its name attribute. Loop through it using <cfloop> and inside the loop place a <cffile action="delete"> to delete all the files that resides in that folder.

    Like this,

    <cfloop query="your_cfdirectory_name">
    <cffile action="delete" file="#directory#\#name#" />
    </cfloop>

    HTH
    Inspiring
    December 15, 2008
    Hi,

    Yeah.. First of all you need to use the Expandpath to get the relative path, then use the "GetDirectoryFromPath" function to get the directory you want to delete.

    Finally perform the delete operation using the <cfdirectory> tag with its action attribute set as "delete".

    HTH