File validation problem

Hello, I have problem with file validation

View:

<?php $form = $this->beginWidget(‘CActiveForm’, [

‘id’ => ‘help-form’,

‘enableAjaxValidation’ => false,

‘htmlOptions’ => array(‘enctype’ => ‘multipart/form-data’),

]); ?>

<?= $form->fileField($model, ‘receipt_copy’); ?>

Model rules:

[‘receipt_copy’, ‘file’, ‘allowEmpty’=>true, ‘types’=>‘jpg, gif, png’, ‘message’ => ‘wrong format’],

Other fields work normal by specified rules, but receipt_copy file field in not working. Why? When I add txt file and submit no errors is showing and form passes.

When i delete ‘allowEmpty’=>true form never passes and all the time the error is showing, so maybe someone can explain why the file is not recognized?

Edit:

Controller:

if (isset($_POST[‘TestForm’]))

{

$model->attributes = $_POST[‘TestForm’];

$model->receipt_copy= CUploadedFile::getInstance($model, ‘receipt_copy’);

if ($model->validate())

{

$model->save();

}

}

model is saved, receipt copy = null.