lazzard / php-ftp-client

:package: Provides helper classes and methods to manage FTP files in an OOP way.
MIT License
90 stars 18 forks source link

Recursive deletion of directories #47

Open skurrilewelt opened 2 weeks ago

skurrilewelt commented 2 weeks ago

Tried to remove a directory structure like this:

-root --content ----file1 ----file2 ----subdir ------file4 ------file3

and the method FtpClient::removeDir(directory) doesn't jumps in to the subdir and as a result the directory content will not be deleted as intended.

Change line 373 in mentioned class to: $this->removeDir($fileInfo['path']); will solve this issue. Or miss I something?

AmraniCh commented 2 weeks ago

Hey, thanks for opening this issue.

print_r($this->isDir("root/content/subdir"));

Check this and see what result you will get, it must be true, otherwise we will use another method listDirDetails to see details about the file root/content/subdir and guess what the problem with it!

skurrilewelt commented 2 weeks ago

I think, it is obvious. You can't call rmdir because it won't delete directories which are not empty.

AmraniCh commented 2 weeks ago

The removeDir method should delete everything within a directory whether it's a file or a directory.