dev-master
9999999-devWoodyAttachments file upload plugin for CakePHP 3
MIT
The Requires
- php >=5.4.16
- cakephp/cakephp ~3.0
- imagine/imagine *
The Development Requires
by GrandFelix
WoodyAttachments file upload plugin for CakePHP 3
CakePHP 3 file upload plugin., (*1)
CakePHP 3 PHP > 5.4.16, (*2)
imagine/imagine is used for image manipulation, (*3)
composer require GrandFelix/WoodyAttachments
run composer update in shell, (*4)
run migrations, (*5)
bin/cake migrations migrate --plugin WoodyAttachments
Add this to your Table file:, (*6)
$this->addBehavior('WoodyAttachments.Upload', [ 'fields' => [ 'images' => [ 'allowedFileTypes' => ['image/jpeg', 'image/png'], 'fileSize' => '2MB', 'numberOfFiles' => 20, 'operations' => [ // remove all this if you don't want to make any file operations 'thumb' => [ // this wil be folder name uploads folder 'thumbnail' => [ 'w' => 270, 'h' => 198 ], 'effects' => ['negative'] // add Imagine effects ], 'mid' => [ // this wil be folder name uploads folder 'widen' => [ 'size' => 600 ], 'effects' => ['grayscale'], 'rotate' => ['degrees' => 90] ], ] ], 'pdf' => [ 'allowedFileTypes' => ['application/pdf'], 'fileSize' => '2MB', ] ] ]);
Currently there are only file operations for images..., (*7)
For multiple upload add this to your view file:, (*8)
echo $this->Form->input('images[]', [ 'multiple' => true, 'label' => 'Pictures', 'type' => 'file' ]);
or this for single upload:, (*9)
echo $this->Form->input('pdf', [ 'label' => 'PDF file', 'type' => 'file' ]);
Form input must have the same name as in configuration in Table when loading behavior. So in this example images and pdf, (*10)
And don't forget to add ['type' => 'file'] in $this->Form->create('ModelName', ['type' => 'file']), (*11)
Change main upload path in config/bootstrap.php, (*12)
WoodyAttachments file upload plugin for CakePHP 3
MIT