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.
composer require albert221/laravel-filepond
If you need to change configuration:
php artisan vendor:publish --provider="Albert221\Filepond\FilepondServiceProvider"
FilePond.setOptions({
server: '/filepond'
});
// 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');
// (...)
}
// 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'
]),
],
];
}
This project was heavily inspired by Sopamo/laravel-filepond.
This project is on Apache 2.0 license.