How to Check if an Attachment Exists
-
To check whether a document contains a certain attachment,
use thesession.advanced
operationsattachments.exists
method. -
Calling
exists
does not load the document or the attachment to the session, and the session will not track them. -
In this page:
Check if attachment exists
$exists = $session
->advanced()
->attachments()
->exists("categories/1-A", "image.jpg");
if ($exists)
{
// attachment 'image.jpg' exists on document 'categories/1-A'
}
Syntax
function exists(?string $documentId, ?string $name): bool;
Parameter | Type | Description |
---|---|---|
$documentId | ?string |
The ID of the document you want to check |
$name | ?string |
The name of the attachment you are looking for |
Return Value | Description |
---|---|
bool |
true - The specified attachment exists for this documentfalse - The attachment doesn't exist for the document |