Answer the question
In order to leave comments, you need to log in
[[+content_image]]
How to upload files with arbitrary extensions in yii2?
I do as it is written here
the rules are
public function rules(){
return [
[['file'], 'file',
'extensions' => 'png, jpg, jpeg, gif, docx, xlsx, pdf, djvu, rar, zip, 7zip,txt',
'maxSize' => Yii::$app->params['fileMaxSize'],
'skipOnEmpty' => false,
'maxFiles' => 5,
//'tooLarge'=>'File has to be smaller than 50MB'
],
[ ['file'], 'required' ],
];
}
Answer the question
In order to leave comments, you need to log in
I 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, then you get a solution to the problem, namely now you can upload files in rar format. Why exactly this format cannot be loaded without checking the conformity of the mime type is not clear.
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' ],
];
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question