CodeIgniter Forums
FTP delete_dir BUG - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: FTP delete_dir BUG (/thread-44980.html)



FTP delete_dir BUG - El Forum - 09-02-2011

[eluser]Glazz[/eluser]
Hello,

I'm having the same problem, mentioned on this topic http://ellislab.com/forums/viewthread/160581/

Whenever i try to delete a directory my web site starts loading....and loading... and then i get a blank page....

This are the errors i'm getting:
Quote:...
ERROR - 07:44:58 03-09-2011 --&gt; Severity: Warning --&gt; ftp_delete() [<a href='function.ftp-delete'>function.ftp-delete</a>]: Could not delete .: Invalid argument C:\Servidor\Web\www\fusephase\sistema\libraries\Ftp.php 430
ERROR - 07:44:59 03-09-2011 --&gt; Severity: Warning --&gt; ftp_rmdir() [<a href='function.ftp-rmdir'>function.ftp-rmdir</a>]: Can't remove directory: Permission denied C:\Servidor\Web\www\fusephase\sistema\libraries\Ftp.php 437
...

... means that are more of the same errors, how to fix this ?

Thank you


-------


Edit:

I went on some testing and the permission denied was for the dir "." and ".." so i edited the code from the Ftp library to this:

Code:
if ($list !== FALSE AND count($list) > 0)
        {
            foreach ($list as $item)
            {
                if($item == '.' or $item == '..'):
                    contunue;
                endif;
                // If we can't delete the item it's probaly a folder so
                // we'll recursively call delete_dir()
                if ( ! @ftp_delete($this->conn_id, $item))
                {
                    $this->delete_dir($filepath.$item);
                }
            }
        }

What i added was this:
Code:
if($item == '.' or $item == '..'):
                    break;
                endif;

And added the $filepath here:
Code:
// If we can't delete the item it's probaly a folder so
                // we'll recursively call delete_dir()
                if ( ! @ftp_delete($this->conn_id, $item))
                {
                    $this->delete_dir($filepath.$item);
                }

Maybe theres another way, but i'm not bothering looking for it.


This way it is deleting recursively all the directories, did not test with files on dirs though, but it should work !?!