PHP code example of daxslab / yii2-uploader-behavior
1. Go to this page and download the library: Download daxslab/yii2-uploader-behavior library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
daxslab / yii2-uploader-behavior example snippets
use daxslab/behaviors/UploaderBehavior;
public function behaviors() {
return [
UploaderBehavior::className()
];
}
public function rules()
{
return [
[['name'], 'ge'], 'image', 'skipOnEmpty' => true],
];
}
$form->field($model, 'image')->fileInput();
use daxslab/behaviors/UploaderBehavior;
public function behaviors() {
return [
[
'class' => UploaderBehavior::className(),
'attributes' => ['avatar'] // or you can use the string format as in 'attributes' => 'avatar'
]
];
}
use daxslab/behaviors/UploaderBehavior;
public function behaviors() {
return [
[
'class' => UploaderBehavior::className(),
'attributes' => ['avatar'] // or you can use the string format as in 'attributes' => 'avatar'
'renamer' => UploaderBehavior::RENAME_MD5 //will encode the filename with md5()
]
];
}
use daxslab/behaviors/UploaderBehavior;
public function behaviors() {
return [
[
'class' => UploaderBehavior::className(),
'attributes' => ['avatar'] // or you can use the string format as in 'attributes' => 'avatar'
'renamer' => function($name, $owner){
return strtoupper($name); //will turn the filename into uppercase
}
]
];
}
php composer.phar
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.