Using "ftp_rename" to move files to other directories on server ftp.....if(ftp_rename($conn_ftp, $xfiles[$i], "./dirx/".$xfiles[$i])) { echo "File $xfiles[$i] moved to ./dirx";} else { echo "ERROR!!!. The file could not be moved";}.....#-->>h2m, bye

You want to make sure you check the existence of the new name before renaming files, because otherwise you could risk losing files. Just do a simple check with ftp_size with the new name. If it's !=-1, you're going to want to throw some kind of error, otherwise you'll be losing a file...

This function isn't only able to rename files, but also folders. And it is not only able to rename them, but also move them, and, in the case of folders, their contents as well (so folders don't have to be empty to move). For example:

<?phpftp_rename($conn_id, "./dir1/dir2/", "./dir3/");?>

Now the folder dir2 (which prevously was in folder dir1) has moved to the same folder as dir1, and it has kept its original contents (the content just moved along).