CRM_Core_Page_AJAX_Attachment
in package
CRM_Core_Page_AJAX_Attachment defines an end-point for AJAX operations which upload file-attachments.
To upload a new file, submit a POST (multi-part encoded) to "civicrm/ajax/attachment". Inputs:
- POST['entity_table']: string
- POST['entity_id']: int
- POST['attachment_token']: string
- FILES[*]: all of the files to attach to the entity
The response is a JSON document. Foreach item in FILES, there's a corresponding record in the response which describes the success or failure.
Note: The permission requirements are determined by the underlying Attachment API.
Table of Contents
Constants
- ATTACHMENT_TOKEN_TTL = 10800
Methods
- _attachFile() : array<string|int, mixed>
- angularSettings() : array<string|int, mixed>
- attachFile() : mixed
- (Page Callback)
- checkToken() : bool
- createToken() : string
- sendResponse() : mixed
Constants
ATTACHMENT_TOKEN_TTL
public
mixed
ATTACHMENT_TOKEN_TTL
= 10800
Methods
_attachFile()
public
static _attachFile(array<string|int, mixed> $post, array<string|int, mixed> $files, array<string|int, mixed> $server) : array<string|int, mixed>
Parameters
- $post : array<string|int, mixed>
-
Like global $_POST.
- $files : array<string|int, mixed>
-
Like global $_FILES.
- $server : array<string|int, mixed>
-
Like global $_SERVER.
Return values
array<string|int, mixed>angularSettings()
public
static angularSettings() : array<string|int, mixed>
Return values
array<string|int, mixed>attachFile()
(Page Callback)
public
static attachFile() : mixed
checkToken()
public
static checkToken(string $token) : bool
Parameters
- $token : string
-
A token supplied by the user.
Tags
Return values
bool —TRUE if the token is valid for submitting attachments
createToken()
public
static createToken() : string
Return values
stringsendResponse()
public
static sendResponse(array<string|int, mixed> $result) : mixed
Parameters
- $result : array<string|int, mixed>
-
List of API responses, keyed by file.