PHPackages                             alareqi/smart-upload - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [File &amp; Storage](/categories/file-storage)
4. /
5. alareqi/smart-upload

ActiveLibrary[File &amp; Storage](/categories/file-storage)

alareqi/smart-upload
====================

Laravel package for mobile file uploads with Livewire-style temporary storage.

v1.3(1mo ago)05[1 PRs](https://github.com/aymanalareqi/smart-upload/pulls)MITPHPPHP ^8.4CI passing

Since Apr 20Pushed 1mo agoCompare

[ Source](https://github.com/aymanalareqi/smart-upload)[ Packagist](https://packagist.org/packages/alareqi/smart-upload)[ Docs](https://github.com/alareqi/smart-upload)[ GitHub Sponsors](https://github.com/aymanalareqi)[ RSS](/packages/alareqi-smart-upload/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (3)Dependencies (13)Versions (5)Used By (0)

Smart Upload
============

[](#smart-upload)

Laravel package for mobile file uploads with temporary storage - no database required.

[![Latest Version on Packagist](https://camo.githubusercontent.com/82d62a3b8bf8a9d8b4e6adc95e9b5422603e533af2d820be439a2e0e35546b9c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f616c61726571692f736d6172742d75706c6f61642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alareqi/smart-upload)[![GitHub Tests Action Status](https://camo.githubusercontent.com/6e2df4047b6adfaf9e1649d5b5edc3c63cd0aab6234ec1097aef51f5f254c889/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c61726571692f736d6172742d75706c6f61642f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/alareqi/smart-upload/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/ac0196e3dc2cebdf0cc44cedc16367facae633e1db70fb2faa90664b3865739b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f616c61726571692f736d6172742d75706c6f61642f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/alareqi/smart-upload/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e54c224edfa07615c0dfd8be2ec0313b19a964fafba7659dc4ba6370fa9fe1b1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f616c61726571692f736d6172742d75706c6f61642e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/alareqi/smart-upload)

This package provides a simple way to handle file uploads from mobile apps. Files are uploaded to a temporary location, then moved to their final destination when the form is submitted.

Installation
------------

[](#installation)

```
composer require alareqi/smart-upload
```

No migrations needed - this package uses file-based temporary storage.

How It Works
------------

[](#how-it-works)

```
┌─────────────┐     /upload-file ┌─────────────┐
│ Mobile App  │ ────────────▶ │   Laravel  │
│             │               │   Server   │
│ 1.Select   │ ◀─────────── │ 2.Return  │
│    file    │    upload   │   signed  │
│             │     URL    │    URL   │
│ 3.Upload   │ ────────────▶ │          │
│    to URL   │  4.Upload  │          │
│             │    file   │          │
│5.Submit     │ ────────────▶ │6.Move to │
│    form    │   form     │ final    │
│             │   data    │ location │
└─────────────┘             └─────────────┘

```

API Endpoints
-------------

[](#api-endpoints)

MethodEndpointDescriptionPOST`/api/upload-file`Upload file### Upload File

[](#upload-file)

Upload a file directly to the endpoint:

```
POST /api/upload-file
Content-Type: multipart/form-data

------WebKitFormBoundary
Content-Disposition: form-data; name="file"; filename="photo.jpg"
Content-Type: image/jpeg

[file content]
------WebKitFormBoundary--
```

Response:

```
{
    "uuid": "abc-123-uuid",
    "path": "tmp/abc-123.jpg",
    "original_name": "photo.jpg",
    "size": 1024,
    "mime_type": "image/jpeg",
    "temp_url": "https://yourapp.com/storage/tmp/abc-123.jpg",
    "expires_at": "2024-01-01T12:00:00Z"
}
```

Laravel Controller Usage
------------------------

[](#laravel-controller-usage)

Use the `HasFileUploads` trait in your controller:

```
use Alareqi\SmartUpload\Concerns\HasFileUploads;
use Illuminate\Http\Request;

class PostController extends Controller
{
    use HasFileUploads;

    public function store(Request $request)
    {
        // Convert temporary upload to permanent storage
        $path = $this->convertUpload(
            $request->image_uuid,  // UUID from mobile
            'posts/images'        // Final directory
        );

        // Save to database
        Post::create([
            'title' => $request->title,
            'image' => $path,
        ]);
    }
}
```

### Multiple Files

[](#multiple-files)

For multiple file uploads, pass an array of UUIDs:

```
use Alareqi\SmartUpload\Concerns\HasFileUploads;
use Illuminate\Http\Request;

class PostController extends Controller
{
    use HasFileUploads;

    public function store(Request $request)
    {
        $imagePaths = [];

        // $request->image_uploads is array: ['uuid1', 'uuid2', 'uuid3']
        foreach ($request->image_uploads as $uuid) {
            $imagePaths[] = $this->convertUpload(
                $uuid,
                'posts/images'
            );
        }

        // Save to database
        Post::create([
            'title' => $request->title,
            'images' => json_encode($imagePaths),
        ]);
    }
}
```

Or convert each with custom filename:

```
foreach ($request->images as $index => $uuid) {
    $path = $this->convertUpload(
        $uuid,
        'posts/images',
        'post_' . $post->id . '_image_' . $index . '.jpg'  // Custom filename
    );
}
```

Configuration
-------------

[](#configuration)

Edit `config/smart-upload.php`:

```
return [
    // Final storage disk
    'disk' => env('SMART_UPLOAD_DISK', 'local'),

    // Temporary directory
    'temp_directory' => env('SMART_UPLOAD_TEMP_DIR', 'smart-upload-tmp'),

    // Hours until temp file expires (also used as cache TTL)
    'expiration_hours' => 24,

    // Max file size in KB
    'max_file_size' => 10240,

    // Allowed mimes
    'allowed_mimes' => ['jpg', 'jpeg', 'png', 'gif', 'pdf'],

    // Cache driver for metadata
    'cache' => [
        'driver' => env('SMART_UPLOAD_CACHE_DRIVER', 'file'),
    ],

    // Temporary upload settings
    'temporary_file_upload' => [
        'disk' => 'local',
        'directory' => 'tmp',
    ],
];
```

Cleanup Command
---------------

[](#cleanup-command)

Run cleanup to delete expired temporary files:

```
php artisan smart-upload:cleanup
```

Schedule it in `app/Console/Kernel.php`:

```
protected function schedule(Schedule $schedule)
{
    $schedule->command('smart-upload:cleanup')->hourly();
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Ayman Alareqi](https://github.com/aymanalareqi)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance92

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 76.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

3

Last Release

45d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a9856614e15a47a8e1eba3b2bc64993fb935ab74de34d4e40b8115bc51f9ff18?d=identicon)[alareqi](/maintainers/alareqi)

---

Top Contributors

[![aymanalareqi](https://avatars.githubusercontent.com/u/77433449?v=4)](https://github.com/aymanalareqi "aymanalareqi (23 commits)")[![FursanAbdulhak](https://avatars.githubusercontent.com/u/65540215?v=4)](https://github.com/FursanAbdulhak "FursanAbdulhak (5 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelalareqismart-upload

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alareqi-smart-upload/health.svg)

```
[![Health](https://phpackages.com/badges/alareqi-smart-upload/health.svg)](https://phpackages.com/packages/alareqi-smart-upload)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.3M41](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k9.9M87](/packages/dedoc-scramble)[spatie/laravel-health

Monitor the health of a Laravel application

88011.3M149](/packages/spatie-laravel-health)[spatie/laravel-passkeys

Use passkeys in your Laravel app

463755.5k32](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3913.7k](/packages/rawilk-profile-filament-plugin)[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24655.3k](/packages/vormkracht10-laravel-mails)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
