PHPackages                             marten-cz/upload-manager - 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. marten-cz/upload-manager

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

marten-cz/upload-manager
========================

Upload manager for Nette framework

7.1.0(6y ago)038MITPHPPHP &gt;=5.6.0

Since Feb 28Pushed 6y agoCompare

[ Source](https://github.com/marten-cz/upload-manager)[ Packagist](https://packagist.org/packages/marten-cz/upload-manager)[ Docs](http://ondraplsek.cz)[ RSS](/packages/marten-cz-upload-manager/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (9)Versions (22)Used By (0)

Upload Manager [![Total Downloads](https://camo.githubusercontent.com/a0e6fe68b3f1a2e405bb7163b9a0bee22a5845c1150633faf92a0bfd2013387d/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6472732f75706c6f61642d6d616e616765722f646f776e6c6f616473)](https://packagist.org/packages/ondrs/upload-manager) [![Build Status](https://camo.githubusercontent.com/fe5eb03e14edc77275bca0a8533eec74a6120be4fcb6587221170f69e1dd6339/68747470733a2f2f7472617669732d63692e6f72672f6f6e6472732f75706c6f61642d6d616e616765722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/ondrs/upload-manager) [![Latest Stable Version](https://camo.githubusercontent.com/b5ef7311230dc00af9d5deb3358cde1726836329488fae63830363c8bb1a80ee/68747470733a2f2f706f7365722e707567782e6f72672f6f6e6472732f75706c6f61642d6d616e616765722f762f737461626c65)](https://packagist.org/packages/ondrs/upload-manager)
==================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================================

[](#upload-manager---)

Upload manager for Nette framework

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

[](#installation)

composer.json

```
"ondrs/upload-manager": "v7.0.0"

```

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

[](#configuration)

Register the extension:

```
extensions:
    uploadManager: ondrs\UploadManager\DI\Extension
```

Minimal configuration:

```
uploadManager:
    relativePath: '/uploads'
```

Full configuration:

```
uploadManager:
    basePath: %wwwDir%
    relativePath: '/uploads'
    fileManager:
        blacklist: {php}
    imageManager:
        maxSize: 1280
        type: jpg
        quality: 80
        saveOriginal: FALSE
        dimensions:
            800:
                - {800, NULL}
                - shrink_only
            500:
                - {500, NULL}
                - shrink_only
            250:
                - {250, NULL}
                - shrink_only
            thumb:
                - {100, NULL}
                - shrink_only
```

In most cases you want to choose the `wwwDir` as your `basePath` (and it is chosen by default) to make your files publicly accessible. `relativePath` is relative to the `basePath`, so complete path where your files will be uploaded looks like this

```
{basePath}/{relativePath}[/{dir}]

```

`dir` is an optional parameter and you can set it during the runtime of your script in the `listen()` or in the `upload()` method.

**fileManager:**

- blacklist
    - array of files extensions which are blacklisted, php is by default

**imageManager**

- maxSize

    - maximum size of an image, if its bigger, it will be automatically resized to this size
    - can be number X coord of an imahe
    - or array \[X, Y\]
- dimensions

    - array of dimensions to which an image will be resized
    - format is

        ```
        PREFIX:
            - {X_SIZE, Y_SIZE}
            - RESIZE_OPTION
        ```
    - `PREFIX` can be whatever you want, it will be added to a resized file: `PREFIX_file.jpg`
    - `Y_SIZE` is optional as well as `RESIZE_OPTION`
    - `RESIZE_OPTION` is set to `Image::SHRINK_ONLY` by default

For example we will set the UploadManager according to the full configuration which is written above.

```
$this->upload->filesToDir('dir/path')

```

Uploading an image file `foo.jpg` with size (1680 x 1050) will result in creation of 5 files: `foo.jpg, 800_foo.jpg, 500_.jpg, 250_foo.jpg, thumb_foo.jpg`which will be saved in the `%wwwDir%/uploads/super/dir`All files are resized proportionally according to their X dimension and saved with a corresponding prefix. File foo.jpg is considered to be an original but it's resized to 1280px.

AWS S3 Support
--------------

[](#aws-s3-support)

Setup your credentials and put your bucket name as a basePath. That's all:

```
uploadManager:
    basePath: 'your-bucket-name'
    relativePath: 'some/path/to/dir'
    s3:
        region: 'eu-central-1'
        version: '2006-03-01'
        credentials:
            key: 'xxxxxxx'
            secret: 'xxxxxxx'
```

Simple as that!

Usage
-----

[](#usage)

Inject `ondrs\UploadManager\Upload` into your presenter or wherever you want

```
/** @var \ondrs\UploadManager\Upload @inject
public $upload;
```

And do an upload.

```
public function renderUpload()
{
    $this->upload->filesToDir('path/to/dir');
}
```

If you want to upload just a single file (for example with a form) call the `singleFileToDir()` method

```
public function processForm($form)
{
    /** @var Nette\Http\FileUpload */
    $fileUpload = $form->values->file;

    $this->upload->singleFileToDir('path/to/dir', $fileUpload);
}
```

Events
------

[](#events)

The real fun comes up with an events. They are here to help you to control and monitor your upload process with an ease.

- onQueueBegin

    - called before the upload starts
    - accept one argument
        1. array of Nette\\Http\\FileUpload objects which *will be uploaded*
- onQueueComplete

    - called when the upload finish
    - accept two arguments
        1. array of Nette\\Http\\FileUpload
        2. array of \\SplFileInfo objects which *were uploaded*
- onFileBegin

    - called before the upload of *each file*
    - accept two arguments
        1. Nette\\Http\\FileUpload
        2. dir which is constructed as `{relativePath}[/{dir}]`
- onFileComplete

    - called after the upload complete of *each file*
    - accept three arguments
        1. Nette\\Http\\FileUpload object of the *original file*
        2. \\SplFileInfo object of the *uploaded file*
        3. dir which is constructed as `{relativePath}[/{dir}]`

Real world example
------------------

[](#real-world-example)

```
/**
 * @param int $eventId
 */
public function uploadAttachment($eventId)
{
    /**
     * @param FileUpload $fileUpload
     * @param \SplFileInfo $uploadedFile
     * @param $path
     */
    $this->upload->onFileComplete[] = function (\SplFileInfo $uploadedFile, FileUpload $fileUpload, $path) use ($eventId) {

        $filename = $uploadedFile->getFilename();

        $this->db->table('crm_attachments')
            ->insert([
                'filename' => $filename,
                'path' => $path,
                'crm_events_id' => $eventId,
            ]);
    };

    /**
     * @param array $files
     * @param array $uploadedFiles
     */
    $this->upload->onQueueComplete[] = function(array $files, array $uploadedFiles) use($eventId) {

        $uploadedFiles = array_map(function($i) {
            return $i->getFilename();
        }, $uploadedFiles);

        $this->db->table('crm_events')
            ->wherePrimary($eventId)
            ->update([
                'text' => implode(';', $uploadedFiles),
            ]);
    };

    $this->upload->filesToDir('attachments/' . $eventId);
}
```

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor1

Top contributor holds 90% 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 ~97 days

Recently: every ~250 days

Total

20

Last Release

2246d ago

Major Versions

v0.5.0 → v6.0.02017-06-21

v0.6.2 → v6.0.22017-06-21

v0.7 → v7.0.02018-04-27

PHP version history (2 changes)v0.1PHP &gt;=5.4.0

v0.4.0PHP &gt;=5.6.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/557fe3fb5c3fb03ff35111f8b8ca28f55293c4779a7c60c0f5135dd331370a02?d=identicon)[marten](/maintainers/marten)

---

Top Contributors

[![ondrs](https://avatars.githubusercontent.com/u/828362?v=4)](https://github.com/ondrs "ondrs (108 commits)")[![marten-cz](https://avatars.githubusercontent.com/u/582397?v=4)](https://github.com/marten-cz "marten-cz (6 commits)")[![Zemistr](https://avatars.githubusercontent.com/u/2613208?v=4)](https://github.com/Zemistr "Zemistr (2 commits)")[![tsusanka](https://avatars.githubusercontent.com/u/1835345?v=4)](https://github.com/tsusanka "tsusanka (1 commits)")[![ondrakub](https://avatars.githubusercontent.com/u/137948?v=4)](https://github.com/ondrakub "ondrakub (1 commits)")[![f3l1x](https://avatars.githubusercontent.com/u/538058?v=4)](https://github.com/f3l1x "f3l1x (1 commits)")[![Cyllenea](https://avatars.githubusercontent.com/u/45451728?v=4)](https://github.com/Cyllenea "Cyllenea (1 commits)")

---

Tags

netteuploadfile-upload

### Embed Badge

![Health badge](/badges/marten-cz-upload-manager/health.svg)

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

###  Alternatives

[contributte/image-storage

Image storage for Nette framework

28749.3k1](/packages/contributte-image-storage)[flowjs/flow-php-server

PHP library for handling chunk uploads. Works with flow.js html5 file uploads.

2451.6M15](/packages/flowjs-flow-php-server)[fof/upload

The file upload extension for the Flarum forum with insane intelligence.

188171.7k15](/packages/fof-upload)[ublaboo/image-storage

Image storage for Nette framework

2913.0k](/packages/ublaboo-image-storage)[coffeecode/uploader

It is a easy PHP upload manager for images, files and media in your application

17149.7k3](/packages/coffeecode-uploader)[iphp/filestore-bundle

Upload files for doctrine entities in symfony 2 project

50143.2k2](/packages/iphp-filestore-bundle)

PHPackages © 2026

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