public function rules(){ return [ [ ['file'], 'file', 'extensions' => 'png, jpg, jpeg, gif, docx, xlsx, pdf, djvu, rar, zip, 7z,txt', 'maxSize' => Yii::$app->params['fileMaxSize'], //'skipOnEmpty' => false, // пропускать, если файл 0 размера 'maxFiles' => 5, //'tooLarge'=>'File has to be smaller than 50MB' ], [ ['file'], 'required' ], ]; } 

Files with the extension: rar, png are not loaded.
And, for example, files with the extension: txt, docx, pdf are loaded, although it seems that the rule is extensions .

Where is the error?

    1 answer 1

    Found a partial solution to the problem, if you look here , namely go to file and to 'checkExtensionByMimeType', and change the default value to false, you get a solution to the problem, but now you can upload files in rar format. It is not clear why this format cannot be loaded without verifying compliance with the maym type.

    The result is:

     public function rules(){ return [ ['file', 'file', 'extensions' => 'tar,png, jpg, jpeg, gif, docx, xlsx, pdf, rar, djvu, zip, 7z, txt,', 'maxSize' => Yii::$app->params['fileMaxSize'], 'maxFiles' => 5, 'checkExtensionByMimeType' => false], [ ['file'], 'required' ], ]; } 

    And partial because casting checkExtensionByMimeType to false may not always be good.