dev-master
9999999-devPackage for attaching files using ajax
MIT
The Requires
by Sergey Yablonskiy
1.0
1.0.0.0Package for attaching files using ajax
MIT
The Requires
by Sergey Yablonskiy
Package for attaching files using ajax
ΠΠ°Π½Π½ΡΠΉ ΠΌΠΎΠ΄ΡΠ»Ρ ΠΏΡΠ΅Π΄Π½Π°Π·Π½Π°ΡΠ΅Π½ Π΄Π»Ρ ΠΏΡΠΈΠΊΠ»Π΅ΠΏΠ»Π΅Π½ΠΈΡ ΡΠ°ΠΉΠ»Π°(ΠΎΠ²) ΠΊ ΠΌΠΎΠ΄Π΅Π»ΡΠΌ ActiveRecord., (*1)
Π£ΡΡΠ°Π½ΠΎΠ²ΠΈΡΠ΅ ΡΠ°ΡΡΠΈΡΠ΅Π½ΠΈΠ΅ Ρ ΠΏΠΎΠΌΠΎΡΡΡ Composer
Π²ΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ Π² ΡΠ΅ΡΠΌΠΈΠ½Π°Π»Π΅
composer require syablonskiy/yii2-attachfile "^1"
Π»ΠΈΠ±ΠΎ Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ Π² ΡΠ΅ΠΊΡΠΈΡ require Π² ΡΠ°ΠΉΠ»Π΅ composer.json
"syablonskiy/yii2-attachfile": "^1"
, (*2)
ΠΠΎΠ±Π°Π²ΡΡΠ΅ ΠΌΠΎΠ΄ΡΠ»Ρ Π² ΠΊΠΎΠ½ΡΠΈΠ³ΡΡΠ°ΡΠΈΡ Π²Π°ΡΠ΅Π³ΠΎ web-ΠΏΡΠΈΠ»ΠΎΠΆΠ΅Π½ΠΈΡ, (*3)
'modules' => [ ... 'attachfile' => [ 'class' => syablonskiy\attachfile\Module::className(), 'storePath' => 'path/to/upload/folder', //default '@app/uploads' 'rules' => [ 'extensions' => 'jpg, zip, mp4', 'maxSize' => 1024*1024, ], 'maxFiles' => 2, //default '3' 'tableName' => 'your_table_name', //default 'attachment' ], ... ]
ΠΡΠΏΠΎΠ»Π½ΠΈΡΠ΅ ΠΌΠΈΠ³ΡΠ°ΡΠΈΡ
php yii migrate --migrationPath=@syablonskiy/attachfile/migrations
, (*4)
ΠΡΠΈΠΊΡΠ΅ΠΏΠΈΡΠ΅ ΠΏΠΎΠ²Π΅Π΄Π΅Π½ΠΈΠ΅ ΠΊ Π²Π°ΡΠ΅ΠΉ ActiveRecord ΠΌΠΎΠ΄Π΅Π»ΠΈ, (*5)
public function behaviors() { return [ \syablonskiy\attachfile\behaviors\AttachmentBehavior::className() ]; }
'modules' => [ ... 'attachfile' => [ 'class' => syablonskiy\attachfile\Module::className(), 'controllerNamespace' => 'syablonskiy\attachfile\commands', ], ... ]
Π Π΄ΠΎΠ±Π°Π²ΡΡΠ΅ Π² ΠΏΠ»Π°Π½ΠΈΡΠΎΠ²ΡΠΈΠΊ Cron ΠΏΠΎΠ΄ΠΎΠ±Π½ΡΡ ΡΡΡΠΎΠΊΡ
*/30 * * * * cd /path/to/your/app && /usr/bin/php yii attachfile/cron/delete-files >/dev/null
ΠΠΎΡΠ»Π΅ ΡΡΠΎΠ³ΠΎ ΠΊΠ°ΠΆΠ΄ΡΠ΅ ΠΏΠΎΠ»ΡΠ°ΡΠ° Π±ΡΠ΄ΡΡ ΡΠ΄Π°Π»ΡΡΡΡΡ Π·Π°Π³ΡΡΠΆΠ΅Π½Π½ΡΠ΅, Π½ΠΎ Π½Π΅ΠΏΡΠΈΠΊΡΠ΅ΠΏΠ»Π΅Π½Π½ΡΠ΅ ΠΊ ΠΌΠΎΠ΄Π΅Π»ΠΈ ΡΠ°ΠΉΠ»Ρ., (*6)
<?= \syablonskiy\attachfile\widgets\InputWidget::widget(['form' => $form]) ?>
$model
<?= \syablonskiy\attachfile\widgets\FilesListWidget::widget( [ 'model' => $model, 'allowDeletion' => true //default 'false' ] ) ?>
ΠΠΏΡΠΈΡ 'allowDeletion' Π΄ΠΎΠ±Π°Π²Π»ΡΠ΅Ρ Π²ΠΎΠ·ΠΌΠΎΠΆΠ½ΠΎΡΡΡ ΠΎΡΠΌΠ΅ΡΠ°ΡΡ ΡΠ°ΠΉΠ»Ρ Π΄Π»Ρ ΡΠ΄Π°Π»Π΅Π½ΠΈΡ, (*7)
Package for attaching files using ajax
MIT
Package for attaching files using ajax
MIT