> ## Documentation Index
> Fetch the complete documentation index at: https://kawax.biz/llms.txt
> Use this file to discover all available pages before exploring further.

# Attachments

> Uitleg over het meesturen van bestanden, directories, selecties en blobs als bijlage bij een prompt met het Laravel Copilot SDK.

## File attachments

Je geeft bestanden of directories op als array, zoals hieronder.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;

$attachments = [
    [
        'type' => 'file',
        'path' => '/path/to/file.php',
        'displayName' => 'My File',// optioneel
    ],
    [
        'type' => 'directory',
        'path' => '/path/to/dir/',
        'displayName' => 'dir',// optioneel
    ],
    [
        'type' => 'selection',
        'filePath' => '/path/to/file.php',
        'displayName' => 'My File',// hier verplicht
        'selection' => [
            'start' => ['line' => 1, 'character' => 10],
            'end' => ['line' => 5, 'character' => 10],
        ],
        'text' => '...',
    ],
    [
        'type' => 'blob',
        'data' => base64_encode(file_get_contents('/path/to/image.png')),
        'mimeType' => 'image/png',
        'displayName' => 'screenshot.png',// optioneel
    ],
];

$response = Copilot::run(prompt: '...', attachments: $attachments);
```

Zo'n formaat onthouden is lastig, dus er zijn helpers beschikbaar om het eenvoudig te maken.

```php theme={null}
use Revolution\Copilot\Facades\Copilot;
use Revolution\Copilot\Support\Attachment;

$attachments = [
    Attachment::file(path: '/path/to/file.php', displayName: 'My File'),
    Attachment::directory(path: '/path/to/dir/', displayName: 'dir'),
    Attachment::selection(filePath: '/path/to/file.php', displayName: 'My File', selection: ['start' => ['line' => 1, 'character' => 10], 'end' => ['line' => 5, 'character' => 10]], text: '...'),
    Attachment::blob(data: base64_encode(file_get_contents('/path/to/image.png')), mimeType: 'image/png', displayName: 'screenshot.png'),
];

$response = Copilot::run(prompt: '...', attachments: $attachments);
```

## Blob attachments

Het type `blob` gebruik je om Base64-geëncodeerde data inline mee te sturen. Zo kun je binaire data zoals afbeeldingen rechtstreeks versturen zonder disk-I/O.

```php theme={null}
use Revolution\Copilot\Support\Attachment;

// Een afbeeldingsbestand Base64-encoden en als bijlage meesturen
$attachment = Attachment::blob(
    data: base64_encode(file_get_contents('/path/to/image.png')),
    mimeType: 'image/png',
    displayName: 'screenshot.png',
);
```

<Info>
  `selection` is nog niet gedocumenteerd in het officiële SDK, dus de details zijn onbekend. Ook voor `github_reference` ontbreekt officiële informatie; ondersteuning volgt later.
</Info>

<Info>
  Zie de [GitHub-repository](https://github.com/invokable/laravel-copilot-sdk) voor de laatste informatie.
</Info>


## Related topics

- [E-mail versturen](/nl/mail.md)
- [Streaming events](/nl/packages/laravel-copilot-sdk/streaming-events.md)
- [Laravel Notification for Discord(Webhook)](/nl/packages/laravel-notification-discord-webhook.md)
- [Laravel AI SDK](/nl/ai-sdk.md)
- [Amazon Bedrock-driver voor de Laravel AI SDK](/nl/packages/laravel-amazon-bedrock.md)
