Table of Contents

exists

API Package Subpackage Class Method Reference Last reviewed Doc status
API Home Package Joomla.Framework Subpackage FileSystem Class JFile Method exists Reference exists() Never Work in Progress

This function is a wrapper for the standard PHP file_exists function. If the file exists, the function returns true. Otherwise, it returns false.

Syntax

boolean exists ( $file )

$file string is a string that contains the file path that is to be checked.

Examples

Example: This example checks if a file exists.

Example

if (JFile::exists( 'images/stories/clock.jpg' )) {
    echo "<h3>File exists!</h3>";
} else {
    echo "<h3>File does not exist!</h3>";
}