Docly Developers
Function API only Updated 17 Oct 2026

saveEmbeddedFolderFile(folderPath, embeddedFilename, data)

Saves an embedded file to the properties document of an existing folder.

The folder must already have a properties document — create one with saveFolderProps. Embedded files that are not referenced by a field in the properties document are deleted automatically, so save a reference to the file afterwards. The call runs as the user who published the site, not as the visitor. Check the visitor's own rights with allowModify before you change anything on their behalf.

See also Path traversal

Parameters

folderPathstringrequired

Absolute path to the existing Docly folder to save the embedded file to.

embeddedFilenamestringrequired

Unique name for the file, at least 20 characters — use a GUID plus the extension.

databyte[] / base64required

The file content to embed, as a byte array or base64-encoded string.

Returns

true when the file is saved. Throws if the folder does not exist or has no properties document (error 1), the name is missing (error 2) or shorter than 20 characters (error 9), the data is not a byte array or base64 string (error 4), or a file with that name already exists (error 5). A target that only exists in the app (publish template) the site runs from throws error 110: the app's files are shared by every site on it and can't be changed from a site.

Example

Normal JavaScript, running in the browser or on the Docly™ server.
// Save an uploaded image on the folder's properties and reference it from a field
let data = docly.getUploadBase64("image");     // the form field name
let name = docly.guid() + ".jpg";
docly.saveEmbeddedFolderFile("/Products", name, data);

// saveFolderProps replaces all properties, so read them first
let props = docly.getFolderProps("/Products") || {};
props.Image1 = name;
docly.saveFolderProps("/Products", props);