L
L
LightSid2018-05-02 22:27:52
Yii
LightSid, 2018-05-02 22:27:52

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) ?>

UPD. Doesn't work in Safari on Iphone, works on Android

Answer the question

In order to leave comments, you need to log in

[[+comments_count]] answer(s)
A
Anton Kudryavtsev, 2020-06-05
@larry7

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 question

Ask a Question

731 491 924 answers to any question