DoppelZ Software

Livewire File Uploads mit Filepond: Ein moderner Ansatz

Entdecke, wie du mit dem Spatie Livewire Filepond Package elegante und benutzerfreundliche File Uploads in deinen Laravel-Anwendungen implementieren kannst. Von der Installation bis zu fortgeschrittenen Features.

Aziz Gasim 30.03.2025 2 Min. Lesezeit Livewire
Livewire

Livewire File Uploads mit Filepond: Ein moderner Ansatz

File uploads are an essential part of many web applications. However, implementing a user-friendly upload system can often be challenging. In this article, I'll introduce you to the Spatie Livewire Filepond package, which elegantly solves this challenge.

What is Filepond?

Filepond is a powerful JavaScript library for file uploads that stands out for its user-friendly interface and extensive functionality. The Spatie Livewire Filepond package makes this library available for Laravel and Livewire applications.

Installation und Setup

Let's start with installing the package:

Terminal
composer require spatie/livewire-filepond

Add the Filepond scripts to your layout. Add the script tag in the <head> section of your layout file (e.g., app.blade.php):

Text
<head>
    <!-- Other meta tags and styles -->
    @filepondScripts
</head>

Basic Implementation

Create a new Livewire component with:

Terminal
php artisan make:livewire FileUpload

Add the WithFilePond trait to your new component:

PHP
use Livewire\Component;
use Spatie\LivewireFilepond\WithFilePond;

class FileUpload extends Component
{
    use WithFilePond;
    
    public $file;
}

In your corresponding Blade view, you can now use the upload component:

Text
<div>
    <x-filepond::upload wire:model="file" />
</div>

Customization Options

The package offers numerous customization options. Here's an example with the most important options:

PHP
<x-filepond::upload 
    wire:model="file"
    multiple
    max-files="5"
    accepted-file-types="image/jpeg,image/png"
    max-file-size="2MB"
    label-idle="Drag and drop your files or <span class='filepond--label-action'>browse</span>"
/>

Advanced Features

The package also supports advanced features such as:

  • Drag & Drop

  • Image Preview

  • Progress Indicator

  • Multilingual Support

  • Customizable Styling Options

Conclusion

The Spatie Livewire Filepond package provides an elegant solution for file uploads in Laravel applications. It combines the user-friendliness of Filepond with the simplicity of Livewire while offering numerous customization options.

Aziz Gasim

Webentwickler

GitHub

Unterstützung bei Laravel oder Filament gesucht?

Ich arbeite für Agenturen und Teams in Laravel-, Livewire- und Filament-Projekten. Remote, 70 € pro Stunde.