Function Updated 23 Oct 2026
getFile(path, [includeMetadata])
Gets a single file with its data and metadata.
Parameters
pathstringrequiredPath of the file from the site root. If no file has that exact path, .hash, .html, /Index.hash, /Index.html and /Index are tried in that order — so a page or folder URL finds its file.
includeMetadatabooloptionalDefault true: the document's fields merged with Docly's file metadata — the same object as getFiles gives with mode "Full". false: only the document's own stored values.
Returns
An object — see getFiles for the fields (mode "Full"). null when no file is found or the path contains .. or a backslash. Throws if the path is empty.
No access check is made. A document in an encrypted folder can only be read after unlockFolder.
Example
Mixed HTML (or any text file) with inline JavaScript between hash signs.
#{
let file = docly.getFile("Test files/Example file.xlsx", true);
var json = JSON.stringify(file);
// Format indent and line breaks in JSON
var pretty = docly.formatJson(json);
// Remove empty lines
var html = pretty.replace(chr(13), "");
write(html);
}#The template above produces this output:
{
"File": "0a4bdde7-e796-4e51-859b-2b7ba13c6f35.xlsx",
"Title": "Example file.xlsx",
"opendoc": "https://docly.net/DsAdeLq7IJ0CERkggJGIU7A?backurl=https%3a%2f%2fdevelopers.docly.net%2fJavaScript%2fFilesystem-functions%2fgetFile",
"Url": "/Test-files/Example-file.xlsx",
"FormName": "Uploaded File",
"DoclyTypeId": 1,
"DoclyTimestamp": "638071602624906438",
"folderpath": "/Test files",
"Tags": [],
"LastModifiedBy": "r@dops.no",
"filename": "Example file.xlsx",
"filepath": "/Test files/Example file.xlsx",
"fileschema": "Uploaded File",
"file": true,
"Guid": "sAdeLq7IJ0CERkggJGIU7A",
"CreatedTime": "2022-12-20T18:09:09.96Z",
"LastModified": "2022-12-20T18:11:02.49Z",
"Filesize": 5710
}