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

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

reich/upload
============

A great class to upload your file or files to the server, could be integreted with laravel

v2.0(8y ago)101355[1 issues](https://github.com/edenreich/PHP-Upload-Class/issues)MITPHPPHP &gt;=5.6.0

Since May 5Pushed 7y ago2 watchersCompare

[ Source](https://github.com/edenreich/PHP-Upload-Class)[ Packagist](https://packagist.org/packages/reich/upload)[ Docs](https://github.com/edenreich)[ RSS](/packages/reich-upload/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (1)Versions (8)Used By (0)

[![](https://camo.githubusercontent.com/66cce96dfd7fcdf831aa44d7f458b50f8897be817e97e66d5f62d4732104532b/68747470733a2f2f64726976652e676f6f676c652e636f6d2f75633f6578706f72743d766965772669643d31386d3644797365696962746259433670614e556a4c5653337252425772735736)](https://camo.githubusercontent.com/66cce96dfd7fcdf831aa44d7f458b50f8897be817e97e66d5f62d4732104532b/68747470733a2f2f64726976652e676f6f676c652e636f6d2f75633f6578706f72743d766965772669643d31386d3644797365696962746259433670614e556a4c5653337252425772735736)

Upload.php
----------

[](#uploadphp)

 [ ![](https://camo.githubusercontent.com/b80d15a6da153cd3ec99b0473b4d21eaf3e28c4af87c21ae45602f219a1766fa/68747470733a2f2f7472617669732d63692e6f72672f6564656e72656963682f5048502d55706c6f61642d436c6173732e7376673f6272616e63683d6d6173746572) ](#) [ ![](https://camo.githubusercontent.com/75173ffbb7d30ec69de61226352e8e58e34f9a311ffc3616e78e22ee860b79bd/68747470733a2f2f706f7365722e707567782e6f72672f72656963682f75706c6f61642f646f776e6c6f616473) ](https://packagist.org/packages/reich/upload) [ ![](https://camo.githubusercontent.com/483fca4e0e7ee845891af7ebf440fe89ded8829bb82d81316a7a0d93225a9624/68747470733a2f2f706f7365722e707567782e6f72672f72656963682f75706c6f61642f762f737461626c65) ](https://packagist.org/packages/reich/upload) [ ![](https://camo.githubusercontent.com/44cfb7b69fb5b6a5bc061aa875450db4c39115f24e54f0bd75e20f529dbc7982/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6564656e72656963682f5048502d55706c6f61642d436c6173732e737667) ](#) [ ![](https://camo.githubusercontent.com/6dad7183c6b02933c93cbedfd76c5c454cf9ee30f993e0500e3fcf61029284cd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6564656e72656963682f5048502d55706c6f61642d436c6173732e737667) ](#) [![](https://camo.githubusercontent.com/4a8e58019b2aeea4fc969d8e0f339d4b42d670199bd532aae7ab26c29477e7cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6564656e72656963682f5048502d55706c6f61642d436c6173732e737667)](https://camo.githubusercontent.com/4a8e58019b2aeea4fc969d8e0f339d4b42d670199bd532aae7ab26c29477e7cc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6564656e72656963682f5048502d55706c6f61642d436c6173732e737667) [ ![](https://camo.githubusercontent.com/e62fbe6da3df64772ecb3c19652783b617da46398f3ddf9db2e153687c211453/68747470733a2f2f706f7365722e707567782e6f72672f72656963682f75706c6f61642f6c6963656e7365) ](https://packagist.org/packages/reich/upload)

PHP Class for uploading file or files to the server Installing
----------

[](#installing)

with composer just run:

```
composer require reich/upload
```

or

You can also download src/Upload.php and simply use it.

As a Package for Laravel
------------------------

[](#as-a-package-for-laravel)

This class is fully integrated into laravel framework using Laravel Auto-Discovery. If you don't use v5.5+ you may import the necessary files path in your /config/app.php file manually:

```
  ...
    "providers" => [
      /*
       * Package Service Providers...
       */
      Reich\Upload\Laravel\UploadServiceProvider::class,
    ],

    "aliases" => [
      "Upload" => Reich\Upload\Laravel\UploadFacade::class,
    ]
  ...
```

Usage
-----

[](#usage)

##### 1) Copy the class that located in the src directory into your project or install it via composer and use it.

[](#1-copy-the-class-that-located-in-the-src-directory-into-your-project-or-install-it-via-composer-and-use-it)

##### 2) Generate an encryption key contains 32 characters or use Reich\\Upload::generateMeAKey(); helper.

[](#2-generate-an-encryption-key-contains-32-characters-or-use-reichuploadgeneratemeakey-helper)

##### 3) Please open the example /demo/index.php file I created to follow and get a better understanding

[](#3-please-open-the-example-demoindexphp-file-i-created-to-follow-and-get-a-better-understanding)

Make sure the form is submitted:

```
if(Upload::submitted())
{
  // rest of the code goes here
}
```

Make an instance of the class

```
$upload = new Upload(YOUR-HTML-INPUT-NAME);
```

Set the directory where you want to upload the files, by default it will upload to your main directroy

```
$upload->setDirectory('img/');
```

You may also specify that you want to create this directory if it's not exists

```
$upload->setDirectory('img/')->create(true);
```

You can set the rules you want for your upload using the following syntax:

```
$upload->addRules([
        'size' => 2000,
        'extensions' => 'png|jpg|pdf'
]);
```

or

```
$upload->addRules([
        'size' => 2000,
        'extensions' => ['png', 'jpg', 'pdf']
]);
```

Set this only if you want to have a encrypt file names(optional for security):

```
$upload->encryptFileNames(true);
```

You may also specify that you want only certain file type to be encrypted like so:

```
$upload->encryptFileNames(true)->only(['jpg']); // only jpg files will be encrypted
```

Or also the following syntax:

```
$upload->encryptFileNames(true)->only('jpg|png|txt'); // only jpg, png and txt files will be encrypted
```

After all is set just run the following command

```
$upload->start();
```

Events
------

[](#events)

Whenever a file has been successfully uploaded.

```
$upload->success(function($file) {
  // handle the file
});
```

If something went wrong listen to error.

```
$upload->error(function($file) {
  // handle the file
});
```

Error Handling
--------------

[](#error-handling)

Check wether there are errors and if there arent errors, proccess the upload:

```
if($upload->unsuccessfulFilesHas())
{
  // display all errors with bootstraps
  $upload->displayErrors();

  // now of course you may formating it differently like so
  foreach($upload->errorFiles as $file)
  {
    // do whatever you want with the file object
    // - $file->name
    // - $file->encryptedName *only if you asked to encrypt*
    // - $file->type
    // - $file->extension
    // - $file->size
    // - $file->error
    // - $file->errorMessage
  }
}
else if($upload->successfulFilesHas())
{
  $upload->displaySuccess();

  // now of course you may formating it differently like so
  foreach($upload->successFiles as $file)
  {
    // do whatever you want with the file object
    // - $file->name
    // - $file->encryptedName *only if you asked to encrypt*
    // - $file->type
    // - $file->extension
    // - $file->size
  }
}
```

#### Here is another method to show you useful errors if something went wrong:

[](#here-is-another-method-to-show-you-useful-errors-if-something-went-wrong)

```
print_r($upload->debug()); // There are some errors only you should look at while setting this up
```

###  Health Score

31

—

LowBetter than 66% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.9% 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 ~87 days

Recently: every ~77 days

Total

6

Last Release

2909d ago

Major Versions

1.0.x-dev → v2.02017-09-10

1.1.x-dev → 2.0.x-dev2018-07-14

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16985712?v=4)[Eden Reich](/maintainers/edenreich)[@edenreich](https://github.com/edenreich)

---

Top Contributors

[![edenreich](https://avatars.githubusercontent.com/u/16985712?v=4)](https://github.com/edenreich "edenreich (88 commits)")[![ikidnapmyself](https://avatars.githubusercontent.com/u/13779866?v=4)](https://github.com/ikidnapmyself "ikidnapmyself (1 commits)")

---

Tags

filefilesupload

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[league/flysystem

File storage abstraction for PHP

13.6k679.9M2.5k](/packages/league-flysystem)[league/flysystem-aws-s3-v3

AWS S3 filesystem adapter for Flysystem.

1.7k285.7M984](/packages/league-flysystem-aws-s3-v3)[kartik-v/bootstrap-fileinput

An enhanced HTML 5 file input for Bootstrap 5.x, 4.x, and 3.x with features for file preview for many file types, multiple selection, ajax uploads, and more.

5.4k8.2M13](/packages/kartik-v-bootstrap-fileinput)[league/flysystem-local

Local filesystem adapter for Flysystem.

225267.1M78](/packages/league-flysystem-local)[kartik-v/yii2-widget-fileinput

An enhanced FileInput widget for Bootstrap 3.x, 4.x &amp; 5.x with file preview, multiple selection, and more features (sub repo split from yii2-widgets)

2357.1M97](/packages/kartik-v-yii2-widget-fileinput)[league/flysystem-memory

In-memory filesystem adapter for Flysystem.

8737.3M264](/packages/league-flysystem-memory)

PHPackages © 2026

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