PHPackages                             makinacorpus/filechunk-bundle - 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. makinacorpus/filechunk-bundle

ActiveSymfony-bundle

makinacorpus/filechunk-bundle
=============================

Javascript file upload widget and form type for Symfony

3.0.2(2y ago)16.9k1GPL-2.0-or-laterPHPPHP &gt;=8.0

Since Mar 1Pushed 2y ago12 watchersCompare

[ Source](https://github.com/makinacorpus/filechunk-bundle)[ Packagist](https://packagist.org/packages/makinacorpus/filechunk-bundle)[ Docs](http://github.com/makinacorpus/filechunk-bundle)[ RSS](/packages/makinacorpus-filechunk-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (46)Used By (0)

File upload widget and file management for Symfony
==================================================

[](#file-upload-widget-and-file-management-for-symfony)

This bundle provides a chunked file upload endpoint, that is tailored to be used with the  widget, but that may be used by any other component,

The chunked file upload endpoint allows:

- very large file uploads,
- resuming broken uploads,
- bypassing most HTTP restrictions on file uploads (size, timeouts);
- avoiding the PHP file upload mecanisms,
- easy to use with a custom form type that can input and output either `File`instances or string URIs.

Known browsers to work with the external JavaScript widget:

- Chrome &lt;= 49
- Edge &lt;= 13
- IE &lt;= 11
- Firefox &lt;= 33
- And probably others, since it only uses a very small subset of the FileReader API.

Setup
=====

[](#setup)

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

[](#installation)

```
composer require makinacorpus/filechunk-bundle
```

Current version does not carry the associated JavaScript widget, you must install it from:

Optionnally, if you are working in a Drupal 7 context, you may just install the following module: instead of manually registering the JavaScript widget.

Basic configuration
-------------------

[](#basic-configuration)

Everything should be auto-configured if you follow the rest of this section.

Custom schemes configuration
----------------------------

[](#custom-schemes-configuration)

Each custom scheme is tied to a custom folder, allowing you to store protocol relative URI in your database instead of absolute path, making the application portable and migrable easily.

Per default, the bundle offers three schemes:

- `private://` for files that should not be accessible via the HTTPd which will default to `%kernel.project_dir/var/private/%`,
- `public://` for files that will be freely visible via the HTTPd, which will default to `%kernel.project_dir/public/files/`,
- `temporary://` for temporary files, which will default to PHP configured temporary folder,
- `upload://` for chunked file upload, which defaults to `temporary://filechunk/`
- `webroot://` for files that are in the public directory, will default to `%kernel.project_dir/public`,

Only the temporary one cannot be configured, all others can be set via the following `.env` file variables:

```
FILE_PRIVATE_DIR="%kernel.project_dir%/var/private"
FILE_PUBLIC_DIR="%kernel.project_dir%/public/files"
FILE_UPLOAD_DIR="%kernel.project_dir%/var/tmp/upload"
FILE_WEBROOT_DIR="%kernel.project_dir%/public"

```

Chunked file upload widget configuration
----------------------------------------

[](#chunked-file-upload-widget-configuration)

Register the routing.yml file in your `config/routes.yaml` file:

```
filechunk:
    resource: "@FilechunkBundle/Resources/config/routing.yml"
    prefix: /
```

And the associated form theme in your `config/packages/twig.yaml` file:

```
twig:
    debug:            "%kernel.debug%"
    strict_variables: false
    form_themes:
        # ...
        - "FilechunkBundle:Form:fields.html.twig"
```

And it should probably work.

Usage
=====

[](#usage)

File manager API
----------------

[](#file-manager-api)

Documentation will come soon.

File widget
-----------

[](#file-widget)

### Basic usage

[](#basic-usage)

Just use the `MakinaCorpus\FilechunkBundle\Form\Type\FilechunkType` form type in your own form builders.

Default values **MUST** be `Symfony\Component\HttpFoundation\File\File`instances, values returned will also be.

### Validation

[](#validation)

You may happily use the `Symfony\Component\Validator\Constraints\File` file constraint to validate you file:

```
    $this
        ->createFormBuilder()
        ->add('photo', FilechunkType::class, [
            'label' => "Photo",
            'multiple' => false,
            'required' => true,
            'constraints' => [
                new Assert\NotBlank(),
                new Assert\File(['mimeTypes' => ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']]),
            ],
        ])
```

### Caveat with multiple values

[](#caveat-with-multiple-values)

When using the `multiple` property set to true, you cannot just apply the `Assert\File` validator, if you do, since the widget will return an array of files the validator will fail. To get around this problem, here is a real life working example on how to tranform the previous example:

```
    $this
        ->createFormBuilder()
        ->add('photo', FilechunkType::class, [
            'label' => "Photo",
            'multiple' => false,
            'required' => true,
            'constraints' => [
                new Assert\NotBlank(),
                new All([
                    'constraints' => [
                        new Assert\File(['mimeTypes' => ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf']]),
                    ],
                ]),
            ],
       ])
```

You may find a better explaination of this there

### Using validation group when working with multiple values

[](#using-validation-group-when-working-with-multiple-values)

Same as upper, but you have validation groups too, you need to cascade the groups in the whole validator chain, this way:

```
    $this
        ->createFormBuilder()
        ->add('photo', FilechunkType::class, [
            'label' => "Photo",
            'multiple' => false,
            'required' => true,
            'constraints' => [
                new Assert\NotBlank([
                    'groups' => ['some', 'group'],
                ]),
                new All([
                    'groups' => ['some', 'group'],
                    'constraints' => [
                        new Assert\File(
                            'groups' => ['some', 'group'],
                            'mimeTypes' => ['image/jpg', 'image/jpeg', 'image/png', 'application/pdf'],
                        ]),
                    ],
                ]),
            ],
       ])
```

### Important notes

[](#important-notes)

- if you provide default values via the form data, and remove it via the UI on the HTML page, you have no way of fetching the removed file list, you must take care of this manually: this will be one of the first feature to be implemented in the future;
- uploaded files are NOT PHP uploaded files, but regular files in your temporary folder, you need to move them manually (you cannot use the `move_uploaded_file()` PHP function;
- You need recent browsers.

That's pretty much it, have fun!

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 85.5% 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 ~55 days

Recently: every ~24 days

Total

44

Last Release

985d ago

Major Versions

0.x-dev → 1.0.0-alpha92018-07-10

1.0.0 → 2.0.0-alpha12019-04-03

1.0.2 → 2.0.0-alpha92019-04-20

1.0.3 → 2.0.0-alpha112019-08-06

2.0.3 → 3.0.0-alpha12023-05-23

PHP version history (5 changes)1.0.0-beta5PHP &gt;=7.0.0

1.0.0-alpha9PHP ^5.5

2.0.0-alpha1PHP &gt;=7.2

3.0.0-alpha1PHP &gt;=7.4

3.0.0PHP &gt;=8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/69252826f3a70a19fc5dcefb7ef9d26d465bb300245641abb4dd89d0ec391a66?d=identicon)[pounard](/maintainers/pounard)

![](https://www.gravatar.com/avatar/d21b98752b406528da88850922b1061f39bf72eb2126b413d5c12e275811a40b?d=identicon)[Makina Corpus](/maintainers/Makina%20Corpus)

---

Top Contributors

[![pounard](https://avatars.githubusercontent.com/u/341855?v=4)](https://github.com/pounard "pounard (59 commits)")[![regilero](https://avatars.githubusercontent.com/u/809883?v=4)](https://github.com/regilero "regilero (6 commits)")[![SimonMellerin](https://avatars.githubusercontent.com/u/29925135?v=4)](https://github.com/SimonMellerin "SimonMellerin (3 commits)")[![Lonnytunes](https://avatars.githubusercontent.com/u/6373159?v=4)](https://github.com/Lonnytunes "Lonnytunes (1 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/makinacorpus-filechunk-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/makinacorpus-filechunk-bundle/health.svg)](https://phpackages.com/packages/makinacorpus-filechunk-bundle)
```

###  Alternatives

[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

19462.3M1.3k](/packages/drupal-core)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[shopware/storefront

Storefront for Shopware

684.2M148](/packages/shopware-storefront)

PHPackages © 2026

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