Yii2-upload
This is a uploaded library with plupload used to upload file., (*1)
NOTE: This extension depends on the yiisoft/yii2 extension. Check the composer.json for this extension's requirements and dependencies. PHP environment require fileinfo
, if upload files is a image imagick
or gd
required. imagick
is recommend and be priority of use, (*2)
Why this extension
To ensure upload large files on most browsers, but in addition to plupload, all other plug-ins in use there is a little problem, such as uploadify, (*3)
Installation
The preferred way to install this extension is through composer., (*4)
Note: Read this web tip /wiki on setting the minimum-stability
settings for your application's composer.json., (*5)
Either run, (*6)
$ php composer.phar require ferguson/yii2-upload "dev-master"
or add, (*7)
"ferguson/yii2-upload": "dev-master"
to the require
section of your composer.json
file., (*8)
Usage
Once the extension is installed, simply modify your application configuration as follows:, (*9)
return [
'modules' => [
'upload' => [
'class' => \ferguson\upload\Module::className(),
'storage' => 'file', // which storage used, default `file` means file will be upload on server. other storages could be supported soon.
'params' => [
'dir' => '@webroot', // file upload directory, default `@webroot`, you can customer.
'url' => '@web', // file uploaded host, default `@web`, you can customer.
'resize' => [
'width' => '90',
'height' => '120',
], // thumb images size.
'watermark' => [
'type' => ['font', 'image'], //null|string|array, which water type, single or both or none.
'position' => '',
//font water setting.
'font' => [
'ttf' => '',
'text' => '',//string, water text.
'size' => '10',// font size, default 10px
],
//image water setting.
'image' => [
'src' => '', //string, water image path, absolute path.
'size' => ''
],
],
],
],
//...
],
//...
];
use in view pages., (*10)
use ferguson\upload\Upload;
//Normal with ActiveForm & model
echo $form->field($model, 'logo')->widget(Upload::className(), [
'clientOptions' => [
'type' => Upload::TYPE_IMAGE,
'max_size' => '2mb',
]
]);
License
yii2-upload is released under the MIT License. See the bundled LICENSE.md
for details., (*11)