PHPackages                             moritz-sauer-13/dropzone - 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. moritz-sauer-13/dropzone

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

moritz-sauer-13/dropzone
========================

An HTML5 upload field for the CMS and frontend forms.

04JavaScript

Since Apr 3Pushed 2y agoCompare

[ Source](https://github.com/moritz-sauer-13/silverstripe-dropzone)[ Packagist](https://packagist.org/packages/moritz-sauer-13/dropzone)[ RSS](/packages/moritz-sauer-13-dropzone/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

\#Fork of unclecheese dropzone just added SS5 requirement

Dropzone for SilverStripe
=========================

[](#dropzone-for-silverstripe)

#### Upload with sanity.

[](#upload-with-sanity)

Introduction
------------

[](#introduction)

The Dropzone module provides `FileAttachmentField`, a robust HTML5 uploading interfaces for SilverStripe, allowing forms to save file uploads to `DataObject` instances.

Features
--------

[](#features)

- Upload on the frontend, or in the CMS, with one consistent interface
- Drag-and-drop uploading
- Automatic client-side thumbnailing
- Grid view / List view
- Upload progress
- Limit file count, file size, file type
- Permissions for removing/deleting files
- Tracking files (remove uploaded files that aren't attached to anything)
- No jQuery dependency

Screenshots
-----------

[](#screenshots)

#### Grid view

[](#grid-view)

[![](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen1.png)](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen1.png)

#### List view

[](#list-view)

[![](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen2.png)](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen2.png)

#### Remove/delete files

[](#removedelete-files)

[![](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen3.png)](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen3.png)

#### Beautiful error handling

[](#beautiful-error-handling)

[![](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen4.png)](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen4.png)

#### Any thumbnail size you like

[](#any-thumbnail-size-you-like)

[![](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen5.png)](https://raw.githubusercontent.com/unclecheese/silverstripe-dropzone/master/images/screenshots/screen5.png)

Usage
-----

[](#usage)

The field instantiates similarly to `UploadField`, taking the name of the file relationship and a label, as the first two arguments. Once instantiated, there are many ways to configure the UI.

```
FileAttachmentField::create('MyFile', 'Upload a file')
  ->setView('grid')
```

If the form holding the upload field is bound to a record, (i.e. with `loadDataFrom()`), the upload field will automatically allow multiple files if the relation is a `has_many` or `many_many`. If the form is not bound to a record, you can use `setMultiple(true)`.

Image-only uploads can be forced using the `imagesOnly()` method. If the form is bound to a record, and the relation points to an `Image` class, this will be automatically set.

### More advanced options

[](#more-advanced-options)

```
FileAttachmentField::create('MyFiles', 'Upload some  files')
  ->setThumbnailHeight(180)
  ->setThumbnailWidth(180)
  ->setAutoProcessQueue(false) // do not upload files until user clicks an upload button
  ->setMaxFilesize(10) // 10 megabytes. Defaults to PHP's upload_max_filesize ini setting
  ->setAcceptedFiles(array('.pdf','.doc','.docx'))
  ->setPermissions(array(
    'delete' => false,
    'detach' => function () {
      return Member::currentUser() && Member::currentUser()->inGroup('editors');
    }
  ));
```

Image uploads get a few extra options.

```
FileAttachmentField::create('MyImage','Upload an image')
    ->imagesOnly() // If bound to a record, with a relation to 'Image', this isn't necessary.
    ->setMaxResolution(50000000); // Do not accept images over 5 megapixels
```

### Default settings

[](#default-settings)

Default values for most settings can be found in the `config.yml` file included with the module.

Usage in the CMS
----------------

[](#usage-in-the-cms)

`FileAttachmentField` can be used as a replacement for `UploadField` in the CMS.

Interacting with the Dropzone interface programatically
-------------------------------------------------------

[](#interacting-with-the-dropzone-interface-programatically)

For custom integrations, you may want to access the `UploadInterface` object that manages the upload UI (see `file_attachment_field.js`). You can do that one of two ways:

- If you have jQuery installed, simply access the `dropzoneInterface` data property of the `.dropzone` element

```
$('#MyFileDropzone').data('dropzoneInterface').clear();
```

- If you are not using jQuery, the `UploadInterface` object is injected into the browser global `window.dropzones`, indexed by the id of your `.dropzone` element.

```
window.dropzones.MyFileDropzone.clear();
```

**NB**: The ID of the actual `.dropzone` element by default is the name of the form input, with 'Dropzone' appended to it, so `FileAttachmentField::create('MyFile')` creates a dropzone with an ID of 'MyFileDropzone'

Tracking / removing unused file uploads
=======================================

[](#tracking--removing-unused-file-uploads)

```
FileAttachmentField::create('MyImage','Upload an image')
    ->setTrackFiles(true)
```

or:

```
FileAttachmentField:
  track_files: true
```

To stop users from uploading lots of files and filling the servers hard-drive via the frontend, you can track each file upload in a record, which is then removed when a form saves using `Form::saveInto($record)`.

If you do not use `Form::saveInto`, you will need to manually untrack the file IDs with:

```
FileAttachmentFieldTrack::untrack($data['MyImageID']);

```

To action the deletion of all the tracked files, you can run the `FileAttachmentFieldCleanTask`.

Troubleshooting
---------------

[](#troubleshooting)

- When using `FileAttachmentField` with `BootstrapForm` be sure to [ignore it from the bootstrap transformation](https://github.com/unclecheese/silverstripe-bootstrap-forms/blob/master/code/BootstrapFieldList.php#L74).

Ring Uncle Cheese.

###  Health Score

14

—

LowBetter than 2% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity19

Early-stage or recently created project

 Bus Factor3

3 contributors hold 50%+ of commits

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/237ff98c98e71b509c4dac62b31efaf7823cca011952ded67579a6cf763b7a47?d=identicon)[moritz-sauer-13](/maintainers/moritz-sauer-13)

---

Top Contributors

[![wilr](https://avatars.githubusercontent.com/u/101629?v=4)](https://github.com/wilr "wilr (13 commits)")[![chromos33](https://avatars.githubusercontent.com/u/2787884?v=4)](https://github.com/chromos33 "chromos33 (9 commits)")[![UndefinedOffset](https://avatars.githubusercontent.com/u/1391558?v=4)](https://github.com/UndefinedOffset "UndefinedOffset (4 commits)")[![nimeso](https://avatars.githubusercontent.com/u/1796069?v=4)](https://github.com/nimeso "nimeso (3 commits)")[![maxime-rainville](https://avatars.githubusercontent.com/u/1168676?v=4)](https://github.com/maxime-rainville "maxime-rainville (2 commits)")[![hdpero](https://avatars.githubusercontent.com/u/13778690?v=4)](https://github.com/hdpero "hdpero (2 commits)")[![doniz](https://avatars.githubusercontent.com/u/4441455?v=4)](https://github.com/doniz "doniz (2 commits)")[![roopezero](https://avatars.githubusercontent.com/u/13299101?v=4)](https://github.com/roopezero "roopezero (2 commits)")[![lozcalver](https://avatars.githubusercontent.com/u/1655548?v=4)](https://github.com/lozcalver "lozcalver (2 commits)")[![silbinarywolf](https://avatars.githubusercontent.com/u/3859574?v=4)](https://github.com/silbinarywolf "silbinarywolf (1 commits)")[![anselmdk](https://avatars.githubusercontent.com/u/1316533?v=4)](https://github.com/anselmdk "anselmdk (1 commits)")[![yvestrublin](https://avatars.githubusercontent.com/u/254103?v=4)](https://github.com/yvestrublin "yvestrublin (1 commits)")[![cjsewell](https://avatars.githubusercontent.com/u/1856199?v=4)](https://github.com/cjsewell "cjsewell (1 commits)")[![digitall-it](https://avatars.githubusercontent.com/u/3578378?v=4)](https://github.com/digitall-it "digitall-it (1 commits)")[![hailwood](https://avatars.githubusercontent.com/u/709773?v=4)](https://github.com/hailwood "hailwood (1 commits)")[![JamesDPC](https://avatars.githubusercontent.com/u/69664712?v=4)](https://github.com/JamesDPC "JamesDPC (1 commits)")[![lekoala](https://avatars.githubusercontent.com/u/250762?v=4)](https://github.com/lekoala "lekoala (1 commits)")[![Martimiz](https://avatars.githubusercontent.com/u/614243?v=4)](https://github.com/Martimiz "Martimiz (1 commits)")[![moritz-sauer-13](https://avatars.githubusercontent.com/u/43135946?v=4)](https://github.com/moritz-sauer-13 "moritz-sauer-13 (1 commits)")[![muskie9](https://avatars.githubusercontent.com/u/870751?v=4)](https://github.com/muskie9 "muskie9 (1 commits)")

### Embed Badge

![Health badge](/badges/moritz-sauer-13-dropzone/health.svg)

```
[![Health](https://phpackages.com/badges/moritz-sauer-13-dropzone/health.svg)](https://phpackages.com/packages/moritz-sauer-13-dropzone)
```

###  Alternatives

[knplabs/gaufrette

PHP library that provides a filesystem abstraction layer

2.5k39.8M123](/packages/knplabs-gaufrette)[google/cloud-storage

Cloud Storage Client for PHP

34390.8M125](/packages/google-cloud-storage)[illuminate/filesystem

The Illuminate Filesystem package.

15261.6M2.6k](/packages/illuminate-filesystem)[superbalist/flysystem-google-storage

Flysystem adapter for Google Cloud Storage

26320.6M30](/packages/superbalist-flysystem-google-storage)[creocoder/yii2-flysystem

The flysystem extension for the Yii framework

2931.7M62](/packages/creocoder-yii2-flysystem)[flowjs/flow-php-server

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

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

PHPackages © 2026

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