Hi,
I have a File model extending Active Record for my files - some info below
public $single_image;
...
public function rules() {
...
[['single_image'], 'file','extensions' => 'png', 'mimeTypes' => 'image/png'],
}
and in my controller for the create action (the $model here refers to a page model)
$model = new Page();
$fileModel = new File();
if ($model->load(Yii::$app->request->post())) {
$image = UploadedFile::getInstance($fileModel, 'single_image');
if ($image && $fileModel->validate()) {
...save...
... do redirection etc
}
}
In my view have
<?= $form->field($fileModel,'single_image')->fileInput();?>
What’s not happening is that if I upload for example a jpeg, I am not getting an error message - when the rule above states that I can only upload png …
Can you help me with this?
Also, any help on using the image validator would be great too!