stechstudio / laravel-upload-server
A robust Laravel backend for handling FilePond uploads with large file chunking support
Installs: 1 440
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- php: ^7.4|^8.0
- illuminate/support: ^6.0|^7.0|^8.0
Requires (Dev)
- orchestra/testbench: ^6.0
- phpunit/phpunit: ^8.0|^9.0
This package is auto-updated.
Last update: 2023-02-15 14:59:17 UTC
README
A robust backend for handling file uploads, batteries included. Supports large chunked uploads. It is currently built for FilePond with planned support for Uppy.
Installation
You know the drill:
composer require stechstudio/laravel-upload-server
Quickstart
1. Add the route
In your routes file add:
UploadServer::route();
Note that this Route can be put inside a Route::group()
, and you can also chain additional route details.
Route::prefix('app')->group(function () { UploadServer::route()->withoutMiddleware('csrf'); });
You will now have a route setup named upload-server
using your default backend. Point your client-side upload integration to this endpoint.
Any file uploads sent to this endpoint will be handled for you and saved at the configured path.
2. Retrieve the saved files
Now when your form is submitted, take the UUIDs and retrieve the saved files:
public function handleFormSubmission(Request $request) { // 'attachments' is the name of the client-side uploader $files = UploadServer::retrieve($request->input('attachments')); }
You will receive back an array of File
objects if there were multiple files submitted, otherwise you will have a single File
instance.
3. Wrap up
You can now simply move the uploaded files to a permanent location, store details in a database, etc.
$files = UploadServer::retrieve($request->input('attachments')); foreach($files AS $file) { $file->store('attachments', 's3'); }
That's it, seriously.
License
The MIT License (MIT). Please see License File for more information.