diff --git a/src/wp-admin/includes/class-wp-filesystem-ftpext.php b/src/wp-admin/includes/class-wp-filesystem-ftpext.php index 541079d7b3..c869ec0dc9 100644 --- a/src/wp-admin/includes/class-wp-filesystem-ftpext.php +++ b/src/wp-admin/includes/class-wp-filesystem-ftpext.php @@ -316,14 +316,16 @@ class WP_Filesystem_FTPext extends WP_Filesystem_Base { * @param string $file * @return bool */ - public function exists($file) { - $list = @ftp_rawlist( $this->link, '-a ' . $file ); + public function exists( $file ) { + $path = dirname( $file ); + $filename = basename( $file ); - if ( empty( $list ) && $this->is_dir( $file ) ) { - return true; // File is an empty directory. + $file_list = @ftp_nlist( $this->link, '-a ' . $path ); + if ( $file_list ) { + $file_list = array_map( 'basename', $file_list ); } - return !empty($list); //empty list = no file, so invert. + return $file_list && in_array( $filename, $file_list ); } /**