Attachments
The Attachments feature allows users to seamlessly share files and media in conversations, enhancing the communication experience.
#Enabling Attachments
Wirechat allows you to control how attachments are handled on a per-panel basis. You can enable all attachments at once, or selectively enable file or media attachments only.
#Enable Attachments
Calling attachments()
enables both file and media attachments.
Setting this to false
will completely disable attachments for the panel.
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//..
->attachments();
}
#File Attachments Only
Use fileAttachments()
if you want to allow only document uploads such as PDFs, ZIPs, or text files.
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//..
->fileAttachments();
}
#Media Attachments Only
Use mediaAttachments()
to allow users to upload images and videos while disabling file uploads.
use Wirechat\Wirechat\Panel;
public function panel(Panel $panel): Panel
{
return $panel
//..
->mediaAttachments();
}
#Sending Attachments
Users can share photos, videos, or documents in conversations by following these steps:
- Open an individual or group chat.
- Click the attachment icon, then choose:
- Photos & Videos: Select images or videos from your device.
- Files: Select documents (e.g., PDFs, text files).
- Preview attachments and add or remove files as needed.
- Click Send to share.
#File System Configuration
WireChat separates storage configuration into two layers for consistency and easier maintenance.
The global WireChat filesystem settings are defined in the wirechat
config file.
This ensures that storage behavior remains consistent across models, jobs, observers, and URL generation.
// config/wirechat.php
return [
//..
/*
|--------------------------------------------------------------------------
| Storage
|--------------------------------------------------------------------------
|
| Global configuration for WireChat file storage. Defines the disk,
| directory, and visibility used for saving attachments.
|
*/
'storage' => [
'disk' => 'public',
'visibility' => 'public',
'directories' => [
'attachments' => 'attachments',
],
],
];
#Upload Settings
#Max Uploads
Control how many files a user can attach per request using maxUploads()
:
$panel->maxUploads(5);
This limits the number of attachments allowed in a single message.
#Media MIME Types
Define the allowed media file types that users can upload in conversations.
$panel->mediaMimes(['png', 'jpg', 'jpeg', 'gif', 'mov', 'mp4']);
This ensures only the specified file formats are accepted for media attachments.
#Media Maximum Upload Size
Set the maximum upload size (in KB) for media files.
$panel->mediaMaxUploadSize(12288); // 12 MB
Uploads exceeding this size will be rejected by the system.
#File MIME Types
Define the allowed document types that users can attach in conversations.
$panel->fileMimes(['zip', 'rar', 'txt', 'pdf']);
Only these file types are permitted for file attachments.
#File Maximum Upload Size
Set the maximum upload size (in KB) for document attachments.
$panel->fileMaxUploadSize(12288); // 12 MB
Any file larger than this will be blocked from upload.
#Validation for Attachments
Wirechat validates attachments at two levels:
- Client-Side Validation – Ensures users only upload files that meet the defined rules.
- Server-Side Validation – Uses Laravel and Livewire backend validation for additional security.
💡 Always keep validation rules in sync with your panel settings. For security and consistency, disk and visibility are never panel-controlled — they are always loaded from config.