Answer the question
In order to leave comments, you need to log in
Why is Yii2 validation not working on the phone?
Please tell me why the file upload validation on the phone may not work, while everything works on the desktop.
Namely, from the phone this field is mandatory, if you upload a file, then all validation passes. Should be made optional
public function rules()
{
return [
[['uploadAvatar'], 'file', 'extensions' => 'jpg, jpeg, png', 'maxSize' => 2097152, 'tooBig' => 'Не больше 2MB'],
];
}
<?= $form->field($model, 'uploadAvatar')->fileInput()->label(false) ?>
Answer the question
In order to leave comments, you need to log in
Indeed, the problem is observed on the iPhone when downloading files from the media library to via Safari, apparently there is a non-standard file extension. Adding the heic extension to the list does not help.
Solution: replace validation by extensions with'mimeTypes' => 'image/*'
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question