我有一个代码:
<?=Html::activeHiddenInput($model, $attribute, $inputParams); ?>
<?=Html::fileInput($id, null, ['id' => $id, 'style' => 'display: none']); ?>
我需要限制扩展名来上传表单中的文件,例如:
True: jpeg, png, jpg
False: *
如何在Yii2中执行此操作?
在模型的规则中,
[['file'], 'file', 'extensions' => 'gif, jpg'],
更多信息,请访问http://stuff.cebe.cc/yii2docs/yii-validators-filevalidator.html