Laravel Chunk Upload
Chunked file uploads for Laravel with support for DropZone, resumable.js, plupload, and more.
Repository Health
Technical Analysis
Laravel Chunk Upload adds robust chunked-upload handling on top of Laravel’s file upload system, letting users upload large files in small pieces that the server reassembles. It ships handlers for the most popular front-end upload libraries, including jQuery-File-Upload (blueimp), plupload, DropZone, resumable.js, FlowJS, and ng-file-upload, so it works with whatever client you already use.
Designed with a minimal memory footprint, the package automatically detects the incoming chunk protocol, stores partial chunks, merges them into the final file, and cleans up stale uploads. It also supports cross-domain requests and integrates with Laravel’s filesystem so completed uploads can be moved to any configured disk.
What You Get
- Handlers for jQuery-File-Upload, plupload, DropZone, resumable.js, FlowJS, and ng-file-upload
- Automatic detection of the incoming chunk protocol via a HandlerFactory
- Low-memory chunk storage, merging, and assembly of the final file
- Automatic cleanup of stale or abandoned chunk files via an artisan command
- Cross-domain request support and integration with Laravel’s filesystem disks
Common Use Cases
- Accepting large file uploads that would exceed PHP upload or memory limits
- Supporting resumable uploads that survive flaky network connections
- Wiring a JavaScript uploader like DropZone or resumable.js to a Laravel backend
Under The Hood
Architecture
An incoming request is passed to a HandlerFactory, which inspects headers and parameters to select a protocol-specific handler extending AbstractHandler (ContentRangeUploadHandler, DropZoneUploadHandler, ResumableJSUploadHandler, FlowJSUploadHandler, NgFileUploadHandler, ChunksInRequest*, SingleUploadHandler). A Receiver drives the handler to persist each incoming chunk as a ChunkFile via the Storage layer, and once the final chunk arrives a FileMerger concatenates the parts into the completed upload under the Save pipeline. Stale chunks are pruned by an artisan command in Commands, and configuration lives under Config with a service provider in Providers.
Tech Stack
PHP 8.2+, built on Laravel’s Illuminate components (http, console, support, filesystem, config) spanning Laravel 9 through 13. It autoloads via PSR-4 under Pion\Laravel\ChunkUpload and stores files through Laravel’s filesystem abstraction, so it is disk-driver agnostic.
Code Quality
The code is well-structured around a factory-plus-handlers pattern with shared logic in an abstract base and traits. A comprehensive PHPUnit test suite mirrors the source layout (Handler, Save, Storage, Providers, Commands) and a filesystem mock enables deterministic tests, reflecting the project’s long maintenance history and high fork ratio.
API Design
Usage is concise: resolve a handler from the request via HandlerFactory, hand it to a Receiver, and receive the merged file on completion. The abstraction hides the differences between client libraries, though correctly wiring the matching front-end uploader gives the integration a moderate learning curve.