Answer the question
In order to leave comments, you need to log in
[[+content_image]]
Yi2 Rules extensions not working correctly?
$model = DynamicModel::validateData(compact('files', 'file', 'userId'),
[
[['userId'], 'integer', 'min' => 1],
[['file'], 'file', 'extensions' => 'xls, xlsx', 'maxSize' => 50 * 1024 * 1024],
[['files'], 'each', 'rule' => ['file', 'extensions' => 'xls, xlsx', 'maxSize' => 50 * 1024 * 1024]],
]);
Разрешена загрузка файлов только со следующими расширениями: xls, xlsx.
Answer the question
In order to leave comments, you need to log in
As IvanMogilev wrote in the code, the problem was in checkExtensionByMimeType
.
That file with the xls extension that I loaded was going through php as an upload. And apparently the library that is used does not prescribe Mime Type, and in Yii this check is enabled by default: https://www.yiiframework.com/doc/api/2.0/yii-valid...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question