albert221/laravel-filepond

FilePond upload handler with more features.


Keywords
filepond, laravel, upload
License
Apache-2.0

Documentation

Albert221/laravel-filepond

Packagist GitHub Workflow Status

This package provides basic FilePond Laravel functionality and helps handle files sent with JS disabled.

This package was written in a real hurry. It may not be well documented or well tested, but should work. Pull Requests fixing that are welcome.

Installation

composer require albert221/laravel-filepond

If you need to change configuration:

php artisan vendor:publish --provider="Albert221\Filepond\FilepondServiceProvider"

Usage

Frontend

FilePond.setOptions({
  server: '/filepond'
});

Backend

// app/Http/Controllers/SomeController.php

public function someAction(Request $request, Filepond $filepond)
{
    // Thanks to `fromRequest` method, it works both when JS was on and off.
    /** @var UploadedFile|[]UploadedFile $file */
    $file = $filepond->fromRequest($request, 'file');
    
    // (...)
}

Validation

// app/Http/Requests/SomeRequest.php

public function rules(FilepondSerializer $filepondSerializer): array
{
    return [
        'foobar' => 'required',
        'file' => [
            'required',
            // It validates both UploadedFile and FilePond's serverId
            new FilepondRule($filepondSerializer, [
                'mimetypes:audio/mpeg'
            ]),
        ],
    ];
}

License

This project was heavily inspired by Sopamo/laravel-filepond.

This project is on Apache 2.0 license.