Forum Moderators: coopster
i have a directory with structure like
project
- images
- include
- classes
- deletefolder.php
i want to delete three folders from project directory which is my main site folder. the page that will take action also resides in project directory. i was using command like
PHP Code:
if(condition) {
unlink("/images");
unlink("images");
//it was not working so i tried
unlink("../images");
}
but both are not working and gives error
Code:
no such directory found
please guide me how can i delete complete folders depending on condition in page.
i also tried rmdir() but it deletes empty folders and i want to delete folder full with php pages.
thanks in advance
it looks like there might be a function in there for this.
from the same page
The directory must be empty, and the relevant permissions must permit this
there are commands to do this from the command line but not with rmdir, rm -rf dirname works but rm -rf is a very dangerous and greedy little function.
You just need to loop through the files in the selected dir and unlink each one, then remove the directory afterwards.
my info.php page is in main Project folder and INCLUDE folder is a sub folder in project like i described in my first post but i dont know why its giving path in warning like
Code:
c:\apache\htdocs\beta opm\include\info.php
coz i dont have info.php in include folder.
any idea?