SuperAPI AI Directory

livewire-file-uploads

Agents & models

View repository

Updated 10-16 09:34

About this skill

Livewire File Upload

File uploads use FilePond, a JavaScript library that provides drag-and-drop, previews, and progress indicators. It integrates with Livewire's temporary upload system.

Activate this skill when:

  • Forms need image/file upload fields

Setup

Add WithFileUploads trait to component:

use Livewire\WithFileUploads;

class CreateEdit extends Component { use WithFormActions, WithFileUploads; }


> Use on component, not form object.

Add filepond to view:

```blade
<x-gt-filepond wire:model="form.tmpUpload" />

Storage Configuration

Configure in form object:

public array $storage = [
    'disk' => 'media',
    'dbColumn' => 'image_name',
    'path' => 'uploads/images',
];

Image Preview

public function featuredImageUrl()
{
    return $this->image_name
        ? Storage::disk('media')->url($this->image_name)
        : url('/svg/placeholder.svg');
}

View:

<img src="{{ $this->imageUrl() }}" alt="{{ $form->title }}">

Component method:

public function imageUrl()
{
    return $this->form->tmpUpload?->temporaryUrl()
        ?? $this->form->editing?->featuredImageUrl()
        ?? url('/svg/placeholder.svg');
}