Image Upload And Validaiton


i have a model User where in rules() i have:

array('image', 'length', 'max'=>150),

array('image','file', 'allowEmpty'=>true, 'types'=>'jpg, gif, png, jpeg', 'maxSize'=>1024 * 1024, 'tooLarge'=>'File has to be smaller than 1MB'),

Part of the update action looks like this:



			$model->attributes = $_POST['User'];

			$model->image = EUploadedImage::getInstance($model,'image');

			$model->birthDate = Helper::createDbDate($model->birthDate);


My User form starts with:






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




	<div class="row-fluid">

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

		<div class="form-4column">



				<div class="user-image">

					<?php if($model->isNewRecord!='1'){

						if (strlen($model->image) != 0)


					<a class="thumbnail"> <img

						src="<?php echo Yii::app() -> request -> baseUrl . '/images/users/' . $model -> id . ".jpg"; ?>" />


					<?php }

					else {


					<a class="thumbnail"> <img

						src="<?php echo Yii::app() -> request -> baseUrl . '/images/users/empty-user.jpg'; ?>" />






				<div class="user-image-select">

					<?php echo $form -> fileField($model, 'image'); ?>




So actually if i am uploading any file bigger than 1 MB and other type of jpg,gif,png and jpeg i should get an error in view, but i am not getting it?

Ah no, sorry it works, but only after the file is uploaded to the server. I would like to check the file before the user uploads a file to server. Is it possible?