dev-master
9999999-devImage upload field for Yii2 forms
GPL-3.0+
The Requires
by Marko Medojevic
extension yii2 form upload image
Image upload field for Yii2 forms
This is replacement of classic file upload HTML form element. Advantages of this field are: * You don't have to handle file upload yourself. It is encapsulated in ImageUploadAction. * ImageUploadAction resolves upload name clashes by default. * If existing model is edited, image field is pre-populated. * Uploaded image won't be lost if form has validation errors after submit. * There is a delete image link besides upload button., (*1)
The preferred way to install this extension is through composer., (*2)
Either run, (*3)
php composer.phar require --prefer-dist mmedojevicbg/yii2-smart-image-field "dev-master"
or add, (*4)
"mmedojevicbg/yii2-smart-image-field": "dev-master"
to the require section of your composer.json
file., (*5)
1) Attach ImageUploadAction to designated controller, (*6)
class SiteController extends BaseController { function actions() { return [ 'upload' => [ 'class' => 'mmedojevicbg\SmartImageField\ImageUploadAction', 'uploadsPath' => \Yii::getAlias('@webroot') . '/uploads', 'uploadsUrl' => '/uploads' ] ]; } }
2) Utilize SmartImageField inside ActiveForm, (*7)
echo SmartImageField::widget(['model' => $model, 'attribute' => 'profile_image', 'uploadsHandler' => '/site/upload']);
Image upload field for Yii2 forms
GPL-3.0+
extension yii2 form upload image