Title: WP_Filesystem_ftpsockets::exists
Published: April 25, 2014
Last modified: February 24, 2026

---

# WP_Filesystem_ftpsockets::exists( string $path ): bool

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#wp--skip-link--target)

Checks if a file or directory exists.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#parameters)󠁿

 `$path`stringrequired

Path to file or directory.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#return)󠁿

 bool Whether $path exists or not.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#source)󠁿

    ```php
    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 = $this->ftp->nlist( $path );

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

    	return ! empty( $list ); // Empty list = no file, so invert.
    	// Return $this->ftp->is_exists($file); has issues with ABOR+426 responses on the ncFTPd server.
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/class-wp-filesystem-ftpsockets.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php#L429)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/class-wp-filesystem-ftpsockets.php#L429-L448)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#related)󠁿

| Uses | Description | 
| [WP_Filesystem_ftpsockets::is_dir()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/is_dir/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Checks if resource is a directory.

  |

| Used by | Description | 
| [WP_Filesystem_ftpsockets::dirlist()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/dirlist/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Gets details for files in a directory or a specific file.

  | 
| [WP_Filesystem_ftpsockets::copy()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/copy/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Copies a file.

  | 
| [WP_Filesystem_ftpsockets::is_file()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/is_file/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Checks if resource is a file.

  | 
| [WP_Filesystem_ftpsockets::get_contents()](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/get_contents/)`wp-admin/includes/class-wp-filesystem-ftpsockets.php` |

Reads entire file into a string.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_filesystem_ftpsockets/exists/?output_format=md#changelog)󠁿

| Version | Description | 
| [6.3.0](https://developer.wordpress.org/reference/since/6.3.0/) | Returns false for an empty path. | 
| [2.5.0](https://developer.wordpress.org/reference/since/2.5.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_filesystem_ftpsockets%2Fexists%2F)
before being able to contribute a note or feedback.