PHPackages                             vkr/symfony-web-uploader - 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. vkr/symfony-web-uploader

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

vkr/symfony-web-uploader
========================

PHP library that simplifies file uploading process to external APIs

1.2.1(9y ago)01311MITPHPPHP &gt;=5.6

Since Aug 8Pushed 9y ago1 watchersCompare

[ Source](https://github.com/wladislavk/SymfonyWebUploader)[ Packagist](https://packagist.org/packages/vkr/symfony-web-uploader)[ Docs](https://github.com/wladislavk/SymfonyWebUploader)[ RSS](/packages/vkr-symfony-web-uploader/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (3)Versions (6)Used By (1)

About
=====

[](#about)

This small library (not a bundle!) simplifies uploading files to an external resource via an API. Since version 1.2, this library depends on Symfony.

This library does not do anything by itself, it is designed to be extended by other bundles or libraries.

Installation
============

[](#installation)

Nothing to install here, really.

Usage
=====

[](#usage)

In Symfony projects
-------------------

[](#in-symfony-projects)

First, you need to create a concrete service implementation of `AbstractUploader` class. This service needs to have a single method called `upload()` that does not accept arguments and by convention should return `$this`.

Here are the properties that can be accessed from inside that method:

- `$this->file` - `Symfony\Component\HttpFoundation\File\File` object acting as a handler for original file
- `$this->uploadURL` - full path to the remote destination folder without trailing slash
- `$this->filename` - the name that will be given for your newly uploaded file - see name changers

If you register this service inside Symfony service container, you will need to install VKRSettingsBundle and add it as an argument to `services.yml`:

```
my_uploader:
    class: AppBundle\MyUploader
    arguments:
        - "@vkr_settings.settings_retriever"

```

Then, you will need to create three settings either as parameters or inside your DB:

- `allowed_upload_types` - an array of MIME types
- `allowed_upload_size` - max size in bytes that can be uploaded
- a setting with arbitrary name with full URL to remote destination folder, with or without trailing slash

See VKRSettingsBundle manual on how settings can be defined.

Here is how you access this service from your controller:

```
$uploader->setUploadDir('my_upload_dir_setting_name');
$file = new Symfony\Component\HttpFoundation\File\File('path/to/file/filename');
$uploader->setFile($file);
$uploader->upload()->checkIfSuccessful();

```

Here `checkIfSuccessful()` checks if the uploaded file exists, has same size and MIME type as the original file and throws exception on error.

If you want to disable checks for size and MIME type, you can call:

```
$uploader->setFile($file, null, false);

```

Name changers
-------------

[](#name-changers)

The second argument to `setFile()` is a name changer object. It defines what name will the new file have. If no name changer is present, the new file will have the same name as the original. Name changers must implement `NameChangerInterface`.

Suppose that you want all files to be renamed with current Unix timestamps, in this case your name changer will look like this:

```
class MyNameChanger implements VKR\SymfonyWebUploader\Interfaces\NameChangerInterface
    public function changeName($originalFilename)
    {
        return time();
    }

    public function setParameters(array $parameters)
    {
    }

```

Then in your controller:

```
$nameChanger = new MyNameChanger();
$uploader->setFile($file, $nameChanger);

```

You do not need to create a name changer if your file was just uploaded by a client and you want to keep the client filename in this case the default new name will correspond to the client filename, not to the PHP temporary name.

Outside of Symfony
------------------

[](#outside-of-symfony)

Things are not that different outside of Symfony, however you cannot use VKRSettingsBundle and must pass your settings as an array:

```
$settings = [
    'allowed_upload_size' => 10000,
    'allowed_upload_types' => ['image/jpeg, 'image/png'],
    'upload_dir' => 'http://my-upload-domain.com/upload-folder/',
];
$uploader = new VKR\SymfonyWebUploader\Uploader(null, $settings);

```

Also, if you are forwarding a file that was just uploaded from a form, you need to initialize it manually:

```
$file = new Symfony\Component\HttpFoundation\File\UploadedFile($_FILES['file']['tmp_name'], $_FILES['file']['name']);
$uploader->setFile($file);

```

###  Health Score

28

—

LowBetter than 52% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~57 days

Total

5

Last Release

3385d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11371476?v=4)[Vladislav Kryshtanovskiy](/maintainers/wladislavk)[@wladislavk](https://github.com/wladislavk)

---

Top Contributors

[![wladislavk](https://avatars.githubusercontent.com/u/11371476?v=4)](https://github.com/wladislavk "wladislavk (6 commits)")

---

Tags

phpapilaravelSymfony2uploadsymfony3drupal8

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/vkr-symfony-web-uploader/health.svg)

```
[![Health](https://phpackages.com/badges/vkr-symfony-web-uploader/health.svg)](https://phpackages.com/packages/vkr-symfony-web-uploader)
```

###  Alternatives

[api-platform/core

Build a fully-featured hypermedia or GraphQL API in minutes!

2.6k50.1M314](/packages/api-platform-core)[sopamo/laravel-filepond

Laravel backend module for filepond uploads

215293.6k3](/packages/sopamo-laravel-filepond)[zgldh/laravel-upload-manager

Upload, validate, storage, manage by API for Laravel 5/6/7/8/9

775.6k2](/packages/zgldh-laravel-upload-manager)[teepluss/cloudinary

Cloudinary API wrapper for Laravel 4

1910.5k](/packages/teepluss-cloudinary)[unisharp/s3-presigned

An AWS S3 package for pre-signed upload purpose in Laravel and PHP.

141.8k](/packages/unisharp-s3-presigned)

PHPackages © 2026

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