Image Not Displaying In The Grid And Rules Not Working

Hi,

I am trying to display the uploaded image in grid. It is displaying while taken from a linux machine, but not showing the image

in IE and Firefox of some windows machines even if the image is present in the location. The same windows browsers are displaying the images of other php applications.


[code]CHtml::image(Yii::app()->baseUrl."/".$data->ImagePath

[/code]

a) Any ideas whether it is releated to code or some borwser settings?

b)Secondly, we have given rules so as to upload only jpeg/gif image in the model file. But it is still uploading the pdf or doc file and ends up in error.


array('ImagePath', 'file','allowEmpty'=>true,'types'=>'jpg, gif, png,jpeg



Any idea why the rule is not getting applied?

Post your


$data->ImagePath

code.

Then


array('ImagePath', 'file','allowEmpty'=>true,'types'=>'jpg, gif, png,jpeg

is incomplete (error posting?)

Hi,


$data->ImagePath

is images/company_banner/11/1367496331_BNR_img1.jpg and the image is present in the specified location.

The rules in the model file is


public function rules()

	{

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

		// will receive user inputs.

		return array(

			

			array('ImagePath', 'length', 'max'=>500),

			array('ImagePath', 'file','allowEmpty'=>true,'types'=>'jpg, gif, png,jpeg,bmp,psd,thm,tif,yuv', 'maxSize' => 1048576, 'tooLarge' => Yii::t('error','Logo file size should be less than 1 MB'), 'wrongType' => Yii::t('error','Logo file type should be JPG, GIF or PNG')),

			

		);

	}

Use publish() method of getAssetManager

CHtml::image(Yii::app()->getAssetManager()->publish(Yii::app()->baseUrl."/".$data->ImagePath);