I am using the CI FTP class, with the function delete_dir, its supposed to delete the folder and everything side of it, however, if the folder has files in it, it won’t delete the folder and outputs an error.
The function is as follows;
function delete_dir($filepath)
{
if ( ! $this->_is_conn())
{
return FALSE;
}
// Add a trailing slash to the file path if needed
$filepath = preg_replace("/(.+?)\/*$/", "\\1/", $filepath);
$list = $this->list_files($filepath);
if ($list !== FALSE AND count($list) > 0)
{
foreach ($list as $item)
{
// 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($item);
}
}
}
Anyone know of any bugs?
ftp_deleteis most likely throwing an error that is not related to deleting a directory (e.g. a permissions issue). To show the error, remove the@beforeftp_delete.