2017 © Pedro Peláez
 

library upload

Framework agnostic upload library

image

siriusphp/upload

Framework agnostic upload library

  • Wednesday, July 25, 2018
  • by adrianmiu
  • Repository
  • 14 Watchers
  • 186 Stars
  • 172,379 Installations
  • PHP
  • 12 Dependents
  • 0 Suggesters
  • 28 Forks
  • 2 Open issues
  • 11 Versions
  • 4 % Grown

The README.md

Sirius\Upload

Source Code Latest Version Software License Build Status Coverage Status Quality Score Total Downloads, (*1)

Framework agnostic upload handler library., (*2)

Features

  1. Validates files against usual rules: extension, file size, image size (wdith, height, ratio). It uses Sirius Validation for this purpose.
  2. Moves valid uploaded files into containers. Containers are usually local folders but you can implement your own or use other filesystem abstractions like Gaufrette or Flysystem.
  3. Works with PSR7 UploadedFileInterface objects and with Symfony's UploadedFiles (see integrations).

Used by Bolt CMS, (*3)

Elevator pitch

use Sirius\Upload\Handler as UploadHandler;
$uploadHandler = new UploadHandler('/path/to/local_folder');

// validation rules
$uploadHandler->addRule('extension', ['allowed' => ['jpg', 'jpeg', 'png']], '{label} should be a valid image (jpg, jpeg, png)', 'Profile picture');
$uploadHandler->addRule('size', ['max' => '20M'], '{label} should have less than {max}', 'Profile picture');

$result = $uploadHandler->process($_FILES['picture']); // ex: subdirectory/my_headshot.png

if ($result->isValid()) {
    // do something with the image like attaching it to a model etc
    try {
        $profile->picture = $result->name;
        $profile->save();
        $result->confirm(); // this will remove the .lock file
    } catch (\Exception $e) {
        // something wrong happened, we don't need the uploaded files anymore
        $result->clear();
        throw $e;
    }
} else {
    // image was not moved to the container, where are error messages
    $messages = $result->getMessages();
}

The Versions

25/07 2018

dev-master

9999999-dev

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

31/07 2017

2.1.1

2.1.1.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

31/03 2016

2.1.0

2.1.0.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

01/09 2015

2.0.1

2.0.1.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

17/05 2015

2.0.0

2.0.0.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

09/04 2015

1.3.1

1.3.1.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

03/02 2015

1.3.0

1.3.0.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

01/10 2014

1.2.1

1.2.1.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

24/04 2014

1.2.0

1.2.0.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

17/04 2014

1.1.0

1.1.0.0

Framework agnostic upload library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload

23/03 2014

1.0.0

1.0.0.0

File upload handling library

  Sources   Download

MIT

The Requires

 

The Development Requires

by Adrian Miu

file form validation upload