Reputation: 133
I am using FileInput widget for yii2 by Kartik.
// your fileinput widget for single file upload
echo $form->field($model, 'image')->widget(FileInput::classname(), [
'options'=>['accept'=>'image/*'],
'pluginOptions'=>['allowedFileExtensions'=>['jpg','gif','png']
]);
The above checks that the image is of type jpg,gif or png. I want to check if the file is of a specified dimensions and also probably file size if that is possible.
Has anyone used Kartik FileInput widget and enforced dimensions for an image?
Upvotes: 1
Views: 1220
Reputation: 3893
You can't do enforce image sizes with the kartik widget, but you can use the built-in image validator in Yii2. Using that you can specify maximum and minimum dimension for your images.
Upvotes: 2