Syntax

attachFile(filePath, pageId)

Description

Adds an attachment to a selected page.

Parameters

Parameter name

Type

Required

Description

filePath

string

Yes

Absolute path to the file.

pageIdnumberYesThe ID of the selected page the file will be attached to.

Return type

boolean (true/false)

The return value represents the success of adding the attachment. If the routine returns true the attachment was successfully added.

Example

string path_to_file;
number page;
path_to_file = "C:/confluence/home/attachment/file_to_attach_1.jpg";
page = 11801;
attachFile(path_to_file, page);

Result: Returns true if the file is at the selected location and the issue exists. It means the file was attached. Returns false if any of the conditions stated before are not met.

Notes

  1. Use forward slashes ( "/" ) for the path.
  2. The path to the attachment must be absolute and point to a location on the server.
  3. If an error occurs, the routine will return false and the error message will be visible in the log.

See also