File Upload - "Image cannot be blank" Error Message

I keep on getting this weired error message when uploading images

For some reason it doesn’t recognize the uploaded file…

It tells me: "Image1 cannot be blank"

Even though I set:

  • ‘enableAjaxValidation’=>false,

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


Here is my Model validation code:

	public function rules()


		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(


			array('titel', 'required', 'on'=>'upload'),

			array('titel', 'match', 'pattern'=>'#^[0-9A-Za-z ]*$#', 'on'=>'upload'),

			array('titel','length','max'=>45, 'on'=>'upload'),	// PW only 20 Chars

			array('titel','length','min'=>6, 'on'=>'upload'),	// PW min 6 Chars

			array('description', 'required', 'on'=>'upload'),

			array('description', 'match', 'pattern'=>'#^[0-9A-Za-z\:\-\.\, ]*$#', 'on'=>'upload'),

			array('description','length','min'=>6, 'on'=>'upload'),	// PW min 6 Chars

			array('image1', 'required', 'on'=>'upload'),

			array('image1', 'file', 

				'types'=>'jpg, gif, png', 

				'maxSize'=>1024 * 1024 * 5,

                		'tooLarge'=>'The file was larger than 5MB. Please upload a smaller file.',

				'wrongType'=>'Please upload only images in the format jpg, gif, png',

				'tooMany'=>'You can upload only 1 avatar',




Here is the view file:

<?php $form=$this->beginWidget('CActiveForm', array(




)); ?>

	<p class="note">Fields with <span class="required">*</span> are required.</p>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">

		<?php echo $form->labelEx($model,'titel'); ?>

		<?php echo $form->textField($model,'titel'); ?>

		<?php echo $form->error($model,'titel'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'description'); ?>

		<?php echo $form->textArea($model,'description',array('rows'=>6, 'cols'=>50)); ?>

		<?php echo $form->error($model,'description'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'year'); ?>

		<?php echo $form->dropDownList($model,'year',array($model->getYearOptions(),)); ?>

		<?php echo $form->error($model,'year'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'image1'); ?>

		<?php echo CHtml::activeFileField($model, 'image1'); ?><br>

		<?php echo $form->error($model,'image1'); ?>


	<div class="row buttons">

		<?php echo CHtml::submitButton($model->isNewRecord ? 'Create' : 'Save'); ?>


<?php $this->endWidget(); ?>

Never Mind…

I forgot to create a CUploadedFile in my Controller…


What a dumb mistake!