fileExists(filePath) Last updated: 17. Oct 2026
Checks whether a file exists in the site, including files the site inherits from the app (publish template) it runs from.
Available in every context. Its counterpart folderExists only exists in API scripts — in a page or template, test a folder with docly.getFolder(path) != null.
See also: folderExists getFile Path traversal
Parameters
| Name | Type | Description |
|---|---|---|
| filePath | string | Absolute path to file to check if exists. |
Returns
true if the file exists, otherwise false (also for an empty path).
Example
Code example (JS)
JS is normal JavaScript either running in the browser or on the Docly™ server.if (docly.fileExists("folder/file1"))
write("The file exists!");