An all in one Laravel backend for FilePond
We currently support the `process` and `revert` methods and are securing those via the Laravel encryption/decryption methods.
Require this package in the composer.json
of your Laravel project.
composer require sopamo/laravel-filepond
If you need to edit the configuration, you can publish it with:
php artisan vendor:publish --provider="Sopamo\LaravelFilepond\LaravelFilepondServiceProvider"
// Get the temporary path using the serverId returned by the upload function in `FilepondController.php`
$filepond = app(\Sopamo\LaravelFilepond\Filepond::class);
$disk = config('filepond.temporary_files_disk');
$path = $filepond->getPathFromServerId($serverId);
$fullpath = Storage::disk($disk)->get($filePath);
// Move the file from the temporary path to the final location
$finalLocation = public_path('output.jpg');
\File::move($fullpath, $finalLocation);
You can use any Laravel disk as the storage for temporary files. If you use a different disk for the temporary files and the final location, you will need to copy the file from the temporary location to the new disk then delete the temporary file yourself.
If you are using the default local
disk, make sure the /storage/app/filepond directory exists in your project and is writable.
This is the minimum Filepond JS configuration you need to set after installing laravel-filepond.
FilePond.setOptions({
server: {
url: '/filepond/api',
process: '/process',
revert: '/process',
patch: "?patch=",
headers: {
'X-CSRF-TOKEN': '{{ csrf_token() }}'
}
}
});