PHPackages                             slince/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. slince/upload

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

slince/upload
=============

Process file uploads with multiple and extensible validation rules

3.1.0(3y ago)710.4k3MITPHPPHP &gt;=8.1

Since Apr 14Pushed 3y ago1 watchersCompare

[ Source](https://github.com/slince/upload)[ Packagist](https://packagist.org/packages/slince/upload)[ RSS](/packages/slince-upload/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (12)Used By (0)

FileUpload
==========

[](#fileupload)

[![Build Status](https://camo.githubusercontent.com/e7ccbce827a35bb79767be565d79b4f241caa02bd153bdfbefc0568d6d7aef93/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f736c696e63652f75706c6f61642f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://app.travis-ci.com/github/slince/upload)[![Coverage Status](https://camo.githubusercontent.com/30f8d76622ff6a3363759417c44ea71bb5dd266b6e9c162b4c8a328925b386f8/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f736c696e63652f75706c6f61642e7376673f7374796c653d666c61742d737175617265)](https://codecov.io/github/slince/upload)[![Latest Stable Version](https://camo.githubusercontent.com/b652f2940906668bdcc79d744d20ee92022d46fbb75f2fc90668ca806f64159f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736c696e63652f75706c6f61642e7376673f7374796c653d666c61742d737175617265266c6162656c3d737461626c65)](https://packagist.org/packages/slince/upload)[![Scrutinizer](https://camo.githubusercontent.com/1f8f064c56008dafff9280a6d45a0553fd103eb233f3354b85486aeff6c6d3a7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f736c696e63652f75706c6f61642e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/slince/upload/?branch=master)

Process uploaded files with multiple and extensible validation rules.

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

[](#installation)

Install via composer

```
$ composer require slince/upload
```

Quick view
----------

[](#quick-view)

```
$builder = new Slince\Upload\UploadHandlerBuilder(); //create a builder.
$handler = $builder
    ->saveTo(__DIR__ . '/dst')
    ->getHandler();

$files = $handler->handle();
print_r($files);
```

Usage
-----

[](#usage)

Assume files are uploaded with this HTML form:

```

```

Server:

```
$builder = new Slince\Upload\UploadHandlerBuilder(); //create a builder.
$handler = $builder
    ->overwrite(true) // open overwrite mode.

    //Custom namer
    ->naming(function (UploadedFile $file) {
        return date('Y/md') . '/' . uniqid() . '.' . $file->getClientOriginalExtension();
    })

    //add constraints
    ->sizeBetween('10m', '20m')
    ->allowExtensions(['jpg', 'txt'])
    ->allowMimeTypes(['image/*', 'text/plain'])

    ->saveTo(__DIR__ . '/dst') //save to local
    ->getHandler();

$files = $handler->handle();

foreach ($files as $file) {
    $uploadedFile = $file->getUploadedFile();
    if ($file->isUploaded()) {
        echo $uploadedFile->getClientOriginalName() . ' upload ok, path:' . $file->getMetadata('spl_file')->getPathname();
    } else {
        echo $uploadedFile->getClientOriginalName() . ' upload error: ' . $file->getException()->getMessage();
    }
    echo PHP_EOL;
}
```

File metadata `$file->getMetadata('metadata name')` is provided by storage layer. if you are using `Local`, the file has a metadata named 'spl\_file', it is an instance of `SplFileInfo`.

If you want access attributes of the file saved in the client, you can use like this.

```
$files['foo']->getUploadedFile()->getClientOriginalName(); // original name
$files['bar']['baz'][0]->getUploadedFile()->getClientOriginalExtension(); // original  extension
$files['bar']['baz'][1]->getUploadedFile()->getClientMimeType(); // original  mime type
```

### Integration with [flysystem](https://github.com/thephpleague/flysystem)

[](#integration-with-flysystem)

```
function createS3Flysystem()
{
    $client = new Aws\S3\S3Client([
        'credentials' => [
            'key'    => 'your-key',
            'secret' => 'your-secret'
        ],
        'region' => 'your-region',
        'version' => 'latest|version',
    ]);
    $adapter = new League\Flysystem\AwsS3v3\AwsS3Adapter($client, 'your-bucket-name');
    $flysystem = new League\Flysystem\Filesystem($adapter);
    return $flysystem;
}

$builder = new Slince\Upload\UploadHandlerBuilder(); //create a builder.
$handler = $builder->setFilesystem(new Slince\Upload\Filesystem\Flysystem(createS3Flysystem()))
    ->getHandler();

$files = $handler->handle();
print_r($files);
```

All files will be automatically uploaded to AWS S3.

License
-------

[](#license)

The MIT license. See [MIT](https://opensource.org/licenses/MIT)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity29

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 80% 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 ~271 days

Recently: every ~415 days

Total

9

Last Release

1152d ago

Major Versions

1.x-dev → 2.x-dev2018-09-04

2.0.0 → 3.0.0-beta12022-12-07

PHP version history (4 changes)1.0.0PHP &gt;=5.5.9

2.x-devPHP &gt;=5.6.0

3.0.0-beta1PHP &gt;=7.1

3.1.0PHP &gt;=8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/3785826?v=4)[Tao](/maintainers/slince)[@slince](https://github.com/slince)

---

Top Contributors

[![slince](https://avatars.githubusercontent.com/u/3785826?v=4)](https://github.com/slince "slince (56 commits)")[![stdex](https://avatars.githubusercontent.com/u/4608879?v=4)](https://github.com/stdex "stdex (14 commits)")

---

Tags

file-uploadfile-upload-validatefile-uploaderuploadvalidationvalidationfileuploadhttp-foundationfile-upload

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[vich/uploader-bundle

Ease file uploads attached to entities

1.9k25.9M116](/packages/vich-uploader-bundle)[sonata-project/media-bundle

Symfony SonataMediaBundle

4625.5M71](/packages/sonata-project-media-bundle)[delight-im/file-upload

Simple and convenient file uploads — secure by default

7210.7k2](/packages/delight-im-file-upload)

PHPackages © 2026

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