Image Cannot Be Blank Problem


I am trying to upload multiple images in a form using Yii. But when submitting the form it is showing ‘image cannot be blank’ to all the file inputs. When debugging I can see the file data in the $_FILES array but the post data shows empty. Below are the code snippets

My Controller

	for($i=1; $i<=$_POST['totalCount']; $i++)


				$model=new ActivityBanners;



				$model->dtCreatedOn=date('Y-m-d H:i:s');















					$file= Yii::app()->params['bannerUploadDir'].$try_file_name;

					$img = Yii::app()->simpleImage->load($file);









Model Code:

public function rules()


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

		// will receive user inputs.

		return array(

			array('iLangId, vcImage', 'required'),

			array('iLangId, iStatus, iUId', 'numerical', 'integerOnly'=>true),

			array('vcImage', 'length', 'max'=>512),

			array('vcType', 'length', 'max'=>100),

			array('dtCreatedOn, dtLastModified', 'safe'),

			array('vcImage', 'file', 'types'=>'jpg, gif, png,', 'maxSize' => 1024 * 1024 * 10,'tooLarge' => 'The file was larger than 10MB. Please upload a smaller file.',    'on' => 'insert'),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('iBannerId, iLangId, vcImage, vcType, iStatus, dtCreatedOn, dtLastModified, iUId', 'safe', 'on'=>'search'),



View Code

	foreach($activityBannerTypes as $values ) { 



	<div class="row">

		<?php echo $form->hiddenField($model,'vcType['.$i.']',array('value'=>$values)); ?>

		<?php echo$form->labelEx($model, $values.' '.'Image'); ?>

		<?php echo $form->fileField($model,'vcImage['.$i.']'); ?>

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


	<?php } 

Thanks in Advance!!

Look this :-

Hi Rvr101,

Thanks for the reply. But that does not serve my requirement. It is for multiple file upload by single file input.

Did u found any solution I had the same problem using muliple file inputs in form.