celestine
01-19-2004, 03:38 AM
Hi all,
I have a problem with a function I got from PHP.net. The function deletes the files in a directory then deletes the empty directory. My problem is that I sometimes have directories 2-levels deep and wants to delete all files and folders from a selected directory and this function will return me an object error when I do so.
Here's the function:-
function removedirR($conn,$dirName){
$ar_files = ftp_nlist($conn, $dirName);
if (is_array($ar_files)){
for ($i=0;$i<count($ar_files);$i++){
$st_file = $ar_files[$i];
if (ftp_size($conn, $st_file) == -1){
$this->removedirR( $st_file);
} else {
ftp_delete($conn, $st_file);
}
}
}
if (ftp_rmdir($conn, $dirName))
return true;
}
Can someone points me in the correct direction? I attempted using ftp_res but I'm stuck on where to add the check into the above function.
thanks.
I have a problem with a function I got from PHP.net. The function deletes the files in a directory then deletes the empty directory. My problem is that I sometimes have directories 2-levels deep and wants to delete all files and folders from a selected directory and this function will return me an object error when I do so.
Here's the function:-
function removedirR($conn,$dirName){
$ar_files = ftp_nlist($conn, $dirName);
if (is_array($ar_files)){
for ($i=0;$i<count($ar_files);$i++){
$st_file = $ar_files[$i];
if (ftp_size($conn, $st_file) == -1){
$this->removedirR( $st_file);
} else {
ftp_delete($conn, $st_file);
}
}
}
if (ftp_rmdir($conn, $dirName))
return true;
}
Can someone points me in the correct direction? I attempted using ftp_res but I'm stuck on where to add the check into the above function.
thanks.