WP_Filesystem_FTPext::exists( string $path ): bool

In this article

Checks if a file or directory exists.

Parameters

$pathstringrequired
Path to file or directory.

Return

bool Whether $path exists or not.

Source

public function exists( $path ) {	/* * Check for empty path. If ftp_nlist() receives an empty path, * it checks the current working directory and may return true. * * See https://core.trac.wordpress.org/ticket/33058. */	if ( '' === $path ) {	return false;	}	$list = ftp_nlist( $this->link, $path );	if ( empty( $list ) && $this->is_dir( $path ) ) {	return true; // File is an empty directory.	}	return ! empty( $list ); // Empty list = no file, so invert. } 

Changelog

VersionDescription
6.3.0Returns false for an empty path.
2.5.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.