Skip to content

Smart UploadClean, painless file uploads for Laravel.

v1.3 • Laravel 11, 12, & 13
Automatic WebP optimization, center-cropping, chunked video streaming, and zero extra database tables. Upload files with one expressive line of code.

Laravel Smart Upload
0
Extra Tables
Clean database, zero migrations
~85%
Smaller Images
Automated WebP compression
< 20ms
Form Submit
Two-step temporary uploads
< 6MB
Memory Peak
Streamed video chunk assembly

Common Recipes ​

php
use App\Models\User;
use KaziOmar\SmartUpload\Facades\Upload;

// Resize to 300x300, convert to WebP, delete the old avatar from disk, and save
$result = Upload::file($request->file('avatar'))
    ->replace($user->avatar)
    ->fit(300, 300)
    ->save('avatars');

$user->update(['avatar' => $result->path]);
php
use KaziOmar\SmartUpload\Facades\Upload;

// 1. Upload in the background when the user picks a file:
$temp = Upload::temp($request->file('avatar'));
// Returns: {"filename": "tmp_a8f9c1b2.jpg", "url": "..."}

// 2. Fast JSON submit when the user clicks 'Save Profile':
$final = Upload::fromTemp($request->string('avatar_token'))
    ->fit(300, 300)
    ->save('avatars');

$user->update(['avatar' => $final->path]);
php
use KaziOmar\SmartUpload\Facades\Upload;

// Handles chunks 1, 2, 3... with zero memory buildup
$chunk = Upload::chunk($request);

if ($chunk->isComplete()) {
    // Merges chunks directly on disk using PHP streams (~5MB RAM)
    $video = $chunk->save('videos');
    
    return response()->json(['path' => $video->path]);
}

return response()->json(['progress' => $chunk->progress()]);
php
use Illuminate\Support\Facades\DB;
use KaziOmar\SmartUpload\Facades\Upload;

DB::transaction(function () use ($request) {
    $receipt = Upload::file($request->file('receipt'))->save('receipts');

    Invoice::create([
        'receipt_path' => $receipt->path,
        'total'        => $request->total,
    ]);

    // If payment fails and throws here, the uploaded file is
    // automatically deleted from disk or S3. No ghost files!
    PaymentService::charge();
});

How it compares

Why developers choose Smart Upload over bloated media packages or manual boilerplate.

FeatureNative LaravelSpatie MediaLibrarySmart Upload
Extra database tablesNone1–3 tablesNone
API StyleBasic proceduralCoupled to modelsFluent chaining
WebP & SizingManual GD codeComplex conversionsOne-liner
Purge on DB rollbackNo (files stay orphaned)NoAutomatic
Two-step SPA / MobileBuild it yourselfComplexBuilt-in (temp / fromTemp)
Video chunk streamingBuild it yourselfNot supportedBuilt-in
Clean up on model deleteManual deletion codeModel eventsSingle Trait

Installation ​

Install the package via Composer:

bash
composer require thekaziomar/laravel-smart-upload

Publish the config file:

bash
php artisan vendor:publish --tag=smart-upload-config