WP_Filesystem_FTPext::exists( string $file )

Checks if a file or directory exists.


Parameters Parameters

$file

(string) (Required) Path to file or directory.


Top ↑

Return Return

(bool) Whether $file exists or not.


Top ↑

Source Source

File: wp-admin/includes/class-wp-filesystem-ftpext.php

	public function exists( $file ) {
		$list = ftp_nlist( $this->link, $file );

		if ( empty( $list ) && $this->is_dir( $file ) ) {
			return true; // File is an empty directory.
		}

		return ! empty( $list ); // Empty list = no file, so invert.
	}


Top ↑

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

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